Last active
December 31, 2015 17:19
-
-
Save 23Skidoo/8019225 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main | |
where | |
main = undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: rose | |
version: 0.1 | |
cabal-version: >= 1.10 | |
build-type: Simple | |
executable one | |
main-is: Main.hs | |
build-depends: base | |
default-language: Haskell2010 | |
ghc-options: -Wall | |
Test-Suite test-one | |
type: exitcode-stdio-1.0 | |
main-is: Tests.hs | |
build-depends: base, HUnit | |
default-language: Haskell2010 | |
ghc-options: -Wall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main ( | |
main | |
) where | |
import Test.HUnit | |
import Data.Char | |
four :: Int | |
four = 4 | |
tests, test1, test2, test3 :: Test | |
test1 = TestCase $ assertEqual "test upCase" "FOO" (map toUpper "foo") | |
test2 = TestCase $ assertEqual "testing that the result is 4" 4 (4::Int) | |
test3 = TestCase $ assertEqual "testing that 4 is 4" four 4 | |
tests = TestList [TestLabel "test1" test1, TestLabel "test2" test2, TestLabel "test3" test3] | |
main :: IO () | |
main = do _ <- runTestTT $ tests | |
return () |
Note that you need to manually set a failing exit code when tests fail for Cabal to know (otherwise, cabal test
would assume that everything passed), like so:
import qualified System.Exit as Exit
main = do
count <- HUnit.runTestTT tests
if HUnit.failures count > 0 then Exit.exitFailure else return ()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks.
Here's the step I used to build it