Code coverage report not generated when Test case failed in android studio using Jacoco plugin.How to skip failed test case and generate code coverage report.
Asked
Active
Viewed 4,183 times
17
-
Did u got the solution to generate the coverage report when test case fails? – zzz Nov 16 '18 at 11:09
-
https://stackoverflow.com/questions/20142486/dont-fail-the-gradle-build-if-a-test-is-failing-with-the-gradle-android-test-pl/25587012#25587012 This may help you. Follow the above link – Kumar Gouda Feb 21 '23 at 13:19
3 Answers
-1
Use the following code in Build.gradle(Module:app)
:
android {
testOptions {
unitTests.all {
setIgnoreFailures(true)
}
}
buildTypes {
debug {
testCoverageEnabled true
}
}
}

Rob
- 26,989
- 16
- 82
- 98

Aravind Raj
- 11
- 1
-
It would be better to add a little bit of commentary to this answer, to explain how it answers the question, and what side-effects there might be. For example, does `setIgnoreFailures(true)` only apply to the coverage report, or does it mean that a build will be considered successful even with failed builds? – DaveyDaveDave Aug 11 '17 at 06:34
-
-3
If you just need to get the report you can add the @Ignore
above the tests in order to temporarily skip them.
When you take care of the reason these tests fail then you just remove the annotation.
This annotation will not run any of the marked tests, you can use it either at class file or at the method/test.

madlymad
- 6,367
- 6
- 37
- 68
-
@Ignore is used to skip the class, not to generate coverage report, when any of the class fails in the test suite. – zzz Nov 16 '18 at 11:08