Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full custom reporter #5

Merged
merged 1 commit into from Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 17 additions & 8 deletions test/Spec.hs
@@ -1,16 +1,25 @@
import Data.Maybe
import Test.HUnit.Base

import Spec.Helpers.CustomReporter
import Spec.Helpers.ProgressReporter
import Spec.NextFromDigits
import Spec.NextFromDigits.Digits

specs :: String -> Test
specs info = test $ info ~:
[ test_NextFromDigits
, test_digits
, test_toNum
, test_next
, test_identity
, test_identity'
]

main :: IO ()
main = runTestTTReport . test $ "Spec " ~:
[ test_NextFromDigits
, test_digits
, test_toNum
, test_next
, test_identity
, test_identity'
]
main = do
runTestTTReport $ specs "Bar specs"
(cc, c) <- runTestC 0 $ specs "Full custom specs"
putStrLn $ show cc
putStrLn $ show c
return ()
32 changes: 32 additions & 0 deletions test/Spec/Helpers/CustomReporter.hs
@@ -0,0 +1,32 @@
module Spec.Helpers.CustomReporter (runTestC) where

import Test.HUnit.Base

startReporter :: ReportStart Int
startReporter s c = do
putStrLn "========================"
putStrLn $ "Start test (" ++ show c ++ "):"
putStrLn $ show s
putStrLn "========================"
return (c + 1)

errorReporter :: ReportProblem Int
errorReporter e i s c = do
putStrLn "========================"
putStrLn $ "Error (" ++ show c ++ "):"
putStrLn $ show i
putStrLn $ show e
putStrLn "========================"
return (c + 1)

problemReporter :: ReportProblem Int
problemReporter e i s c = do
putStrLn "========================"
putStrLn $ "Problem (" ++ show c ++ "):"
putStrLn $ show i
putStrLn $ show e
putStrLn "========================"
return (c + 1)

runTestC :: Int -> Test -> IO (Counts, Int)
runTestC c t = performTest startReporter errorReporter problemReporter 0 t