hunit

Why does my HUnit test suite fail but pass successfully in Cabal?

荒凉一梦 提交于 2021-02-07 11:54:21
问题 If I have test/Test.hs with module Main where import Test.HUnit test1 :: Test test1 = TestCase $ assertEqual "Should be one" 1 5 test2 :: Test test2 = TestCase $ assertEqual "Shold both be zero" 0 0 main :: IO Counts main = runTestTT $ TestList [test1, test2, test1] and a .cabal with test-suite my-test type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Test.hs build-depends: base >= 4.8.1.0 && <4.9, HUnit >= 1.3 default-language: Haskell2010 and I run cabal test --show-details='always'

Why does my HUnit test suite fail but pass successfully in Cabal?

拟墨画扇 提交于 2021-02-07 11:54:06
问题 If I have test/Test.hs with module Main where import Test.HUnit test1 :: Test test1 = TestCase $ assertEqual "Should be one" 1 5 test2 :: Test test2 = TestCase $ assertEqual "Shold both be zero" 0 0 main :: IO Counts main = runTestTT $ TestList [test1, test2, test1] and a .cabal with test-suite my-test type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Test.hs build-depends: base >= 4.8.1.0 && <4.9, HUnit >= 1.3 default-language: Haskell2010 and I run cabal test --show-details='always'

How do I test for an error in Haskell?

白昼怎懂夜的黑 提交于 2019-12-30 04:37:05
问题 I want to be able to make sure a function will throw an error when it receives and invalid value. For example, let says I have a function pos that only returns a positive number: pos :: Int -> Int pos x | x >= 0 = x | otherwise = error "Invalid Input" This is a simplistic example, but I hope you get the idea. I want to be able to write a test case that will expect an error and consider it a passing test. For example: tests = [pos 1 == 1, assertError pos (-1), pos 2 == 2, assertError pos (-2)]

How to use HUnit and Cabal to do Automated Testing?

自闭症网瘾萝莉.ら 提交于 2019-12-12 07:44:55
问题 I've been fighting with Cabal for a good portion of a day trying to make its automated testing features work with HUnit. I've read the documentation here and here, and I have my Test-Suite section set up like it shows, but whenever I try and build the package using cabal build Cabal says that the only Test-Suite type supported is exitcode-stdio-1.0 . What gives? 回答1: Background So here's the deal, the documentation on the cabal site is "future documentation," that is, not all of those

Current state of integrating unit tests with Haskell's Cabal?

ぃ、小莉子 提交于 2019-12-03 03:45:33
问题 When i google for how to integrate unit tests with cabal files, i either find http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program which does not seem to describe the integration of HUnit/QuickCheck with the Cabal file or i see messages like "wait for Cabal x.y which will support cabal test" but i can not find any documentation for this either How would you run all unit test using cabal (for example everytime i do a "cabal build") today? 回答1: Make sure you have the latest version

Current state of integrating unit tests with Haskell's Cabal?

╄→гoц情女王★ 提交于 2019-12-02 17:12:28
When i google for how to integrate unit tests with cabal files, i either find http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program which does not seem to describe the integration of HUnit/QuickCheck with the Cabal file or i see messages like "wait for Cabal x.y which will support cabal test" but i can not find any documentation for this either How would you run all unit test using cabal (for example everytime i do a "cabal build") today? tibbe Make sure you have the latest version of Cabal and cabal-install installed. Have a test-suite section in your .cabal file. See this section

How do I test for an error in Haskell?

我的未来我决定 提交于 2019-11-30 13:51:58
I want to be able to make sure a function will throw an error when it receives and invalid value. For example, let says I have a function pos that only returns a positive number: pos :: Int -> Int pos x | x >= 0 = x | otherwise = error "Invalid Input" This is a simplistic example, but I hope you get the idea. I want to be able to write a test case that will expect an error and consider it a passing test. For example: tests = [pos 1 == 1, assertError pos (-1), pos 2 == 2, assertError pos (-2)] runTests = all (== True) tests [My Solution] This is what I ended up going with based on @hammar's