Code Monkey home page Code Monkey logo

Comments (8)

autonomousapps avatar autonomousapps commented on May 24, 2024 1

Nope, this is a com.android.application module. It implements an interface defined in a com.android.library module, if that matters. Also, FWIW, I have not experienced trouble running tests in library modules. But in all modules, I can't click into code previews in the test reports 🤷‍♂️

from android-junit5.

mannodermaus avatar mannodermaus commented on May 24, 2024

The plugin will set up the sourceDirectories and classDirectories itself when it constructs the Jacoco companion tasks, based on what is configured in the Android variant. So you're saying that the report is generated and you do see the coverage, but you don't have code preview inside of the report? Right now, there's no way to specify additional class and source directories, you can only filter out certain inputs. However, if you see the coverage itself, this is configured properly. I'm curious if there is more configuration for Jacoco so that it enables code preview, too.

from android-junit5.

abeenf avatar abeenf commented on May 24, 2024

Yes the report is generated correctly and coverage is visible but no code preview. I was trying to find out more about the directories since that is the suggestion on the Jacoco FAQ (http://www.jacoco.org/jacoco/trunk/doc/faq.html). Maybe the issue lies with one of these parts?

  1. Class files must be compiled with debug information to contain line numbers.
  2. Source files must be properly supplied at report generation time. I.e. specified source folders must be the direct parent of the folders that define the Java packages.

Sorry I can't be of much help. I'm barely learning to use this.

from android-junit5.

mannodermaus avatar mannodermaus commented on May 24, 2024

Thanks for the research! I will experiment with the second point in particular, maybe there is something we can improve on.

from android-junit5.

autonomousapps avatar autonomousapps commented on May 24, 2024

I came here to report this very issue.
screenshot from 2018-03-29 21-39-19
As you can see, you cannot click any method to dive into the code preview. I thought this was because I was looking at a Kotlin source file, but the issue is the same for Java source files. In the past, with JUnit4 tests, I had to manually configure Jacoco tasks, and I was able to overcome this by explicitly specifying the source directories like so:

task connectedDebugAndroidTestCoverage(dependsOn: ["connectedDebugAndroidTest"], type: JacocoReport) {
    sourceDirectories = files(["src/main/java", "src/debug/java", "src/flavor/buildtype/java" /* etc */])
}

from android-junit5.

mannodermaus avatar mannodermaus commented on May 24, 2024

Thanks for the input! Are you experiencing this inside a library module, by any chance? Trying to identify if this might be related to #72. The sourceDirectories are supposed to be identical between a JUnit task and its Jacoco companion, but looks like there's something amiss here.

from android-junit5.

mannodermaus avatar mannodermaus commented on May 24, 2024

After investigating and experimenting a little more, I found that the directories applied to the plugin's Jacoco tasks aren't correct. When using the auto-generated tasks, this is the output (for a sample project with a single file, com.example.MyActivity:


[android-junit5]: Assembled Jacoco Code Coverage for JUnit 5 Task 'junitPlatformTestDebug':
[android-junit5]: |__ Execution Data: /home/workspace/MyApplication/app/build/jacoco/junitPlatformTestDebug.exec
[android-junit5]: |__ Source Dirs: /home/workspace/MyApplication/app/src/main/java/com/example/MyActivity.java
[android-junit5]: |__ Class Dirs: /home/workspace/MyApplication/app/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/example/MyActivity.class

The directories aren't directories at all, but rather a list of the included files themselves. When I use a custom task on the same execution data, I get the proper code preview:

task customJacoco(type: JacocoReport) {
  executionData(file("build/jacoco/junitPlatformTestDebug.exec"))
  sourceDirectories = files("src/main/java")
  classDirectories = files("build/intermediates/javac/debug/compileDebugJavaWithJavac/classes")
}

screen shot 2018-05-02 at 12 43 54

I'll make sure to have this case handled correctly by the plugin.

from android-junit5.

mannodermaus avatar mannodermaus commented on May 24, 2024

This will be fixed in the upcoming 1.0.32 release. Until then, please refer to the latest SNAPSHOT version! Thanks again for reporting.

from android-junit5.

Related Issues (20)

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.