【发布时间】:2018-03-21 00:56:24
【问题描述】:
我正在尝试确保我的 ScalaCheck 属性运行 500 次,而不是默认的 100 次。我在配置这个时遇到了麻烦。
class BlockSpec extends Properties("BlockSpec") with BitcoinSLogger {
val myParams = Parameters.default.withMinSuccessfulTests(500)
override def overrideParameters(p: Test.Parameters) = myParams
property("Serialization symmetry") =
Prop.forAll(BlockchainElementsGenerator.block) { block =>
logger.warn("Hex:" + block.hex)
Block(block.hex) == block
}
}
但是当我实际运行这个测试时,它只显示 100 个测试成功通过
编辑:
$ sbt
[info] Loading project definition from /home/chris/dev/bitcoins-core/project
[info] Set current project to bitcoin-s-core (in build file:/home/chris/dev/bitcoins-core/)
> test-only *BlockSpec*
[info] + BlockSpec.Serialization symmetry: OK, passed 100 tests.
[info] Elapsed time: 1 min 59.775 sec
[info] ScalaCheck
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[info] ScalaTest
[info] Run completed in 2 minutes.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[success] Total time: 123 s, completed Aug 1, 2016 11:36:17 AM
>
我如何实际将其传递给我的财产?
【问题讨论】:
-
我猜你是从 sbt 调用的?你能告诉我们你是怎么称呼这个属性的吗?也许尝试使用 REPL 中的
property.check? -
我确实使用 sbt,我会将命令添加到 OP
-
看起来当我从控制台运行它时,我也只通过了 100 个测试
scala> res1._2.check + OK, passed 100 tests. -
res1._2.check(_.withMinSuccessfulTests(500))呢? -
这确实有效,但它并没有真正回答最初的问题——应该有一些方法可以将这些参数传递给类并使用 sbt 运行它们
标签: scala scalacheck