QuickCheck退出时的失败状态以及cabal集成 [英] QuickCheck exit status on failures, and cabal integration
问题描述
我试图了解如何集成cabal的一些quickcheck测试。此要点表明 quickCheck
函数返回非-zero状态失败,但我没有得到这种行为,所以使用cabal的 exitcode-stdio-1.0
test-suite类型似乎不适用于我,除非我想要在我的测试中调用 error
。
I'm trying to understand how to integrate some quickcheck tests with cabal. This gist suggests that the quickCheck
function returns non-zero status on failure, but I am not getting that behavior, so using cabal's exitcode-stdio-1.0
test-suite type doesn't seem to work for me unless I want to call error
all over my tests.
cabal 用户指南也提到了一个详细 - 1.0
测试套件,但是AFAICT这样做还没有存在。那还是这样吗?
The cabal user guide also mentions a detailed-1.0
test-suite, but AFAICT this doesn't exist yet. Is that still the case?
从这个,很多人都在使用 test-framework package 。这对我来说太过分了,但是我应该使用什么?
It seems from answers like this one that a lot of people are using the test-framework package. That's overkill for me, but is that what I should use?
我对这种情况感到不满意。
I'm left kind of unsatisfied by this situation.
我正在使用的版本:
cabal-install version 0.10.2
using version 1.10.1.0 of the Cabal library
QuickCheck-2.4.1.1
推荐答案
查看 quickCheck
的实现,它确实永远不会退出程序。但是,您可以使用 quickCheckResult
:
Looking at quickCheck
's implementation, it indeed never exits the program. However, you can easily implement this behaviour using quickCheckResult
:
import Control.Monad
import Test.QuickCheck
import Test.QuickCheck.Test
import System.Exit
main :: IO ()
main = do
result <- quickCheckResult prop
unless (isSuccess result) exitFailure
我的理解是 detailed-1.0
尚未被认为已准备好供普遍使用,而且 exitcode-stdio-1.0
仍然是推荐的测试解决方案。
My understanding is that detailed-1.0
is not considered ready for general use yet, and that exitcode-stdio-1.0
is still the recommended testing solution for now.
这篇关于QuickCheck退出时的失败状态以及cabal集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!