简体   繁体   English

是否可以对组合单元和集成测试施加最小覆盖范围?

[英]Can one impose a coverage minimum for combined unit and integration tests?

When I run unit tests for my sbt project (with sbt clean coverage test ), I get code coverage of ~77%. 当我为我的sbt项目运行单元测试时(使用sbt clean coverage test ),我获得了大约77%的代码覆盖率。

When I run integration tests ( sbt clean coverage it:test ), I get code coverage of ~10%. 当我运行集成测试( sbt clean coverage it:test )时,我获得了大约10%的代码覆盖率。

When I run both ( sbt clean coverage test it:test ), I get code coverage of ~84%. 当我同时运行它们( sbt clean coverage test it:test )时,我获得了大约84%的代码覆盖率。

I'd like to set an aggressive code coverage minimum and fail the build if it's not met, but if I add these build settings: 如果不满足,我想设置一个积极的代码覆盖率最小化并使构建失败,但如果我添加这些构建设置:

coverageMinimum := 83
coverageFailOnMinimum := true

...and then run sbt clean coverage test it:test , the coverage minimum is checked after the unit tests, before the integration tests can run, and the build fails: ...然后运行sbt clean coverage test it:test ,在单元测试之后检查覆盖最小值,在集成测试运行之前,构建失败:

[error] Coverage is below minimum [77.0% < 83.0%]

If I put it:test before test , it's even worse ( [10.0% < 83.0%] ). 如果我把it:testtest ,它甚至更糟( [10.0% < 83.0%] )。

Is there any way to stipulate that the 83% minimum should apply only after both unit and integration tests have run? 有没有办法规定只有在单元测试和集成测试运行后才能应用83%的最小值? Or am I doomed to setting the coverage minimum meetable by my unit tests alone, and always remembering to put test before it:test on the command line? 或者我注定要通过单独的单元测试来设置最小可覆盖范围,并且始终记得在it:test之前进行test it:test在命令行上进行it:test

Automatic post-test coverage minimum check was removed in version 1.3.4 (see issue https://github.com/scoverage/sbt-scoverage/issues/132 ). 版本1.3.4中删除了自动测试后覆盖率最低检查(请参阅问题https://github.com/scoverage/sbt-scoverage/issues/132 )。

Upgrade plugin version to latest 1.3.5 and call coverageReport after all tests, eg: 将插件版本升级到最新的1.3.5并在所有测试后调用coverageReport ,例如:

sbt clean coverage test it:test coverageReport

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM