简体   繁体   English

Jacoco使用AndroidJunit进行Android Instrumentation测试

[英]Jacoco for Android Instrumentation Test using AndroidJunit

I am facing an issue while creating an test report using jacoco for Android Instrumentation Test. 使用jacoco for Android Instrumentation Test创建测试报告时,我遇到问题。 I am using AndroidJUnit4 to create test cases. 我正在使用AndroidJUnit4创建测试用例。

Here is what I am doing: 这是我在做的事情:

  1. Created the test cases and placed under default src/androidTest directory. 创建测试用例并将其放置在默认的src / androidTest目录下。 Tested all the test cases executed properly. 测试所有测试用例是否正确执行。
  2. Integrated jacoco, taken the reference from https://github.com/mgouline/android-samples/blob/master/jacoco/jacoco.gradle 集成的jacoco,取自https://github.com/mgouline/android-samples/blob/master/jacoco/jacoco.gradle的参考
  3. When I try to generate the jacoco report I am getting an error on gradle console that :app:testDebugUnitTestCoverage SKIPPED but no other warning or error. 当我尝试生成jacoco报告时,我在gradle控制台上遇到了一个错误::app:testDebugUnitTestCoverage SKIPPED,但没有其他警告或错误。
  4. Also when I write the test cases using jUnit and everything is working as expected. 同样,当我使用jUnit编写测试用例时,一切都按预期工作。 I able to see the reports generated in the build directory. 我可以看到在生成目录中生成的报告。 Note : As these are unit test cases so I put them in src/test not in src/androidTest 注意 :因为这些是单元测试用例,所以我将它们放在src / test中而不是src / androidTest中

Does anybody has idea how we can create reports using jacoco for test cases created using AndroidJunit4. 有谁知道我们如何使用jacoco为使用AndroidJunit4创建的测试用例创建报告。

Thanks 谢谢

Its very simple to get reports for just put the flag 只需标记一下即可获取报告非常简单
debug {testCoverageEnabled = true} 调试{testCoverageEnabled = true}

All other stuff will be taken care by gradle. 所有其他东西将由gradle照顾。 You can see the report under build/reports/coverage/buildType/ 您可以在build / reports / coverage / buildType /下查看报告

I hope it will save somebody else's effort 我希望这可以节省别人的精力

可能是因为您给定的覆盖范围路径不正确-:使用gradle的prinln方法,还如下给出变量的打印值。

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

相关问题 关于使用AndroidJunitRunner和AndroidJUnit4的Android Instrumentation测试java.lang.UnsatisfiedLinkError - Android Instrumentation test java.lang.UnsatisfiedLinkError on using AndroidJunitRunner and AndroidJUnit4 无法解析符号“ AndroidJUnit4”以进行Android工具测试 - Cannot resolve symbol 'AndroidJUnit4' for Android instrumentation test 在带有 ProGuard 的 Android Instrumentation 测试中使用 Kotlin 协程 - Using Kotlin coroutines in Android Instrumentation test with ProGuard Android 使用 Mockito 进行仪器测试:mocking 不工作 - Android Instrumentation test using Mockito: mocking not working Android Gradle Jacoco:用于集成测试的离线工具 - Android Gradle Jacoco: offline instrumentation for integration tests 使用无活动的检测的Android单元测试 - Android unit test using instrumentation without Activity 使用Android仪器测试测量性能 - Measuring performance using Android instrumentation test 使用PoweMockito进行Android Instrumentation测试 - Android Instrumentation Test with PoweMockito android检测列表视图 - android instrumentation test for listview Android Instrumentation测试用例 - Android Instrumentation Test Case
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM