{-# LANGUAGE NoImplicitPrelude #-} -- : dep tasty -- : dep tasty-hunit -- : dep tasty-quickcheck module Biz.Test ( Tree, group, unit, prop, with, (@=?), (@?=), (@?!=), ) where import Alpha hiding (group) import qualified Test.Tasty as Tasty import Test.Tasty.HUnit ((@=?), (@?=)) import qualified Test.Tasty.HUnit as HUnit import qualified Test.Tasty.QuickCheck as QuickCheck type Tree = Tasty.TestTree group :: Tasty.TestName -> [Tasty.TestTree] -> Tasty.TestTree group = Tasty.testGroup unit :: Tasty.TestName -> HUnit.Assertion -> Tasty.TestTree unit = HUnit.testCase prop :: QuickCheck.Testable a => Tasty.TestName -> a -> Tasty.TestTree prop = QuickCheck.testProperty with :: -- | Startup IO a -> -- | Shutdown (a -> IO ()) -> -- | A test group where the first argument is a function that gets the resource (IO a -> Tree) -> Tree with = Tasty.withResource -- | How is this not part of HUnit?? assertNotEqual :: (Eq a, Show a, HasCallStack) => -- | The message prefix String -> -- | The not-expected value a -> -- | The actual value a -> HUnit.Assertion assertNotEqual preface notexpected actual = unless (actual /= notexpected) (HUnit.assertFailure msg) where msg = (if null preface then "" else preface ++ "\n") ++ "expected not: " ++ show notexpected ++ "\n but got: " ++ show actual (@?!=) :: (Eq a, Show a, HasCallStack) => -- | The not-expected value a -> -- | The actual value a -> HUnit.Assertion expected @?!= actual = assertNotEqual "" expected actual