简体   繁体   English

当所有带有testthat的测试通过时,covr显示覆盖率为0%

[英]covr shows 0% of coverage while all tests with testthat pass

I have built a package with unit tests for most of the functions. 我为大多数功能构建了带有单元测试的软件包。 The package has a standard structure: 该软件包具有标准结构:

package:
  - R/
    - file1.R
    - file2.R
    - ...
  - tests/
    - testthat/
      - tests_for_file1.R
      - tests_for_file2.R
      - ...
  - ...

Calling a function devtools::check() in R console gives me no errors 在R控制台中调用函数devtools::check()不会给我任何错误

R CMD check results
0 errors | 1 warning  | 1 note

Calling a function devtools::test() is also successful 调用函数devtools::test()也成功

OK:       72
Failed:   0
Warnings: 0
Skipped:  0

However covr::package_coverage() give me this result 但是covr::package_coverage()给我这个结果

package Coverage: 0.00%
R/file1.R: 0.00%
R/file2.R: 0.00%
...

Why? 为什么?

I found the answer to the problem here 我在这里找到了问题的答案

I was missing package/tests/testthat.R file, which can be set up with usethis::use_testthat() and usethis::use_test() . 我缺少了package/tests/testthat.R文件,可以使用usethis::use_testthat()usethis::use_test() It helped me. 它帮助了我。

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

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