8
如果我有test/Test.hs
与当我的测试失败时,为什么我的HUnit测试套件会通过?
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]
与
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
一个.cabal
,我跑cabal test --show-details='always'
然后我得到
Test suite my-test: RUNNING...
### Failure in: 0
test/Test.hs:6
Should be one
expected: 1
but got: 5
### Failure in: 2
test/Test.hs:6
Should be one
expected: 1
but got: 5
Cases: 3 Tried: 3 Errors: 0 Failures: 2
Test suite my-test: PASS
为什么我的测试套件过程,当我有失败?同样,如果我cabal sdist
我不会收到我的测试失败的警告。
我曾经研究过'detailed-0.9',但[得到了氛围](http://stackoverflow.com/a/18686329/656912),它不够稳定和难以使用。 – orome
@raxacoricofallapatorius,可能。我从来都没有搞错过;我只在现有项目中对现有测试套件进行了一些扩展。 – dfeuer
@dfeuer:我使用了'ExitSuccess'和'ExitFailure'的方法,但是如果我运行'cabal test --show-details ='always'',那么它不起作用 - build说测试套件:PASS有一个失败。你能推荐一个解决方法吗? – altern