Created
December 6, 2014 02:19
-
-
Save Risto-Stevcev/a9798abc898fba99235b to your computer and use it in GitHub Desktop.
Adding HUnit to Cabal packages
This file contains 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 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
-- Initial SampleTest.cabal generated by cabal init. For further | |
-- documentation, see http://haskell.org/cabal/users-guide/ | |
name: SampleTest | |
version: 0.1.0.0 | |
-- synopsis: | |
-- description: | |
-- license: | |
author: Risto Stevcev | |
maintainer: [email protected] | |
-- copyright: | |
-- category: | |
build-type: Simple | |
-- extra-source-files: | |
cabal-version: >=1.10 | |
executable SampleTest | |
main-is: Main.hs | |
-- other-modules: | |
-- other-extensions: | |
build-depends: base, Cabal | |
-- hs-source-dirs: | |
default-language: Haskell2010 | |
Test-Suite SampleTestSuite | |
type: exitcode-stdio-1.0 | |
main-is: Tests.hs | |
build-depends: base, | |
test-framework, | |
test-framework-hunit, | |
HUnit | |
default-language: Haskell2010 |
This file contains 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 | |
import Test.Framework | |
import Test.Framework.Providers.HUnit | |
import Test.HUnit | |
testfoo = TestCase $ assertEqual "Foo == Foo" | |
"Foo" "Foo" | |
testfoo2 = TestCase $ assertEqual "Foo != Bar" | |
"Foo" "Bar" | |
-- hUnitTestToTests: Adapt an existing HUnit test into a list of test-framework tests | |
tests = hUnitTestToTests $ TestList [TestLabel "testfoo" testfoo, | |
TestLabel "testfoo2" testfoo2] | |
main = defaultMain tests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To kick things off, just do:
cabal install && cabal configure --enable-tests && cabal test