Giter Site home page Giter Site logo

rafaeltoledo / unified-code-coverage-android Goto Github PK

View Code? Open in Web Editor NEW
173.0 9.0 34.0 149 KB

Mixing the coverage data from both Instrumented and Unit tests

License: Apache License 2.0

Java 100.00%
jacoco android testing gradle code-coverage kotlin

unified-code-coverage-android's Introduction

unified-code-coverage-android's People

Contributors

cs-rafael-toledo avatar rafaeltoledo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unified-code-coverage-android's Issues

Consider adding multilple flavors to the app

Great guide and examples! Thank you!

I think the example can benefit from adding multiple flavors, or at least some comments related to them. Unfortunately, jacoco does not provide any error messages if folders with execution data are empty or non-existent. This will be the case if a multi-flavor app is tested. Some adjustments are required to the paths:

val javaClasses = fileTree("dir" to "$buildDir/intermediates/javac/developDebug", "excludes" to fileFilter)
val kotlinClasses = fileTree("dir" to "$buildDir/tmp/kotlin-classes/developDebug", "excludes" to fileFilter)
val mainSrc = "$projectDir/src/main/java"

sourceDirectories.setFrom(files(listOf(mainSrc)))
classDirectories.setFrom(files(listOf(javaClasses, kotlinClasses)))
executionData.setFrom(fileTree(
        "dir" to project.buildDir,
        "includes" to listOf(
                "jacoco/testDevelopDebugUnitTest.exec",
                "outputs/code_coverage/developDebugAndroidTest/connected/**/*.ec"
        )
))

I am getting below error

Unknown Execution value 'ANDROIDX_TEST_ORCHESTRATOR'. Possible values are 'host', 'android_test_orchestrator'.
Open File

I am facing below error could you help me out

Task :app:connectedDebugAndroidTest
Starting 0 tests on SM-J700F - 6.0.1

com.android.builder.testing.ConnectedDevice > No tests found.[SM-J700F - 6.0.1] FAILED
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @test annotations).

Task :app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:connectedDebugAndroidTest'.

There were failing tests. See the report at: file:///D:/Satsuma/AAA_Sample/QA/unified-code-coverage-android-master/app/build/reports/androidTests/connected/index.html

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 55s
52 actionable tasks: 1 executed, 51 up-to-date
1:15:09 PM: Task execution finished 'createDebugCoverageReport'.

a discussion than an issue

Hi,

I tried out the sample, it works perfectly fine. Thing doesn't work as expected when I added a new file.

I added a file UnitTestSample in main/java/src.

`public class UnitTestSample {

public static int add(int i, int j){
    return i+j;
}

}`
and a UnitTest file in test/java/src

public class UnitTest { @Test public void testAdd(){ assertEquals(2,UnitTestSample.add(1,1)); } }

What I expected from the coverage report is that it should shows 2 classes, MainActivity & UnitTestSample under package net.rafaeltoledo.coverage but it shows only MainActivity. The coverage report is at app/build/reports/jacoco/jacocoTestReport/html/index.html.

Is there anything I missed out?

Instrumentation tests coverage

Noticed that coverage only works for Robolectric unit test, but not for instrumentation MainActivityTest with ActivityTestRule. So if I remove MainActivityUnitTest coverages goes to 0%, but MainActivityTest is still running. Is it limitation of jacoco/report or I miss something?

Allow generating report even if any test case fail.

As of now, if any test fails, Jacoco doesn't generate the code coverage report in percentage. Can we generate a test coverage report even if any test fails?

Let's say we have 5 instrumentation test cases, and only one of them is failing. But 4 of them are successfully executed. Can we check, how much code is covered by 4 passed tests ignoring 1 failed test?

Wrong JaCoCo version?

After running ./gradlew createDebugCoverageReport task and opening report (app/build/reports/coverage/debug/index.html) I can see in the right bottom corner this text version:
Created with JaCoCo 0.7.9.201702052155

Shouldn't the JaCoCo version be the same as version defined in ext.jacocoVersion ๐Ÿค”

Report says 0% test coverage

Ive cloned the repo and run ./gradlew clean jacocoTestReport and the resulting app/build/reports/coverage/debug/net.rafaeltoledo.coverage/index.html report says 0% test coverage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.