Comments (8)
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.
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.
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?
- Class files must be compiled with debug information to contain line numbers.
- 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.
Thanks for the research! I will experiment with the second point in particular, maybe there is something we can improve on.
from android-junit5.
I came here to report this very issue.
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.
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.
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")
}
I'll make sure to have this case handled correctly by the plugin.
from android-junit5.
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)
- Instrumented Testsuites run on JUnit4 Runner HOT 1
- Might be better to migrate CI to Github Actions
- Add support for Gradle Plugins DSL HOT 2
- org.junit.runners.model.InvalidTestClassError starting with Android Studio Dolphin | 2021.3.1 HOT 8
- Build broken when using kotlin 1.7.21 HOT 1
- Clarification with regards to JaCoCo HOT 2
- AGP 8.0.0-alpha10 HOT 6
- Various 'Unable to resolve' log messages for Android tests HOT 4
- Parallel concurrent execution of instrumentation tests HOT 6
- NoClassDefFoundError: org/jetbrains/kotlin/gradle/plugin/KotlinPluginKt with Kotlin 1.8.20 HOT 5
- `@Tag` at the class level results in test number mismatch HOT 6
- NoSuchMethodError: 'org.gradle.api.provider.Property org.gradle.api.reporting.ConfigurableReport.getOutputLocation()' on Gradle 7.5.1 HOT 3
- Is it possible to run junit5 tests with robolectric? HOT 5
- Encountering problems when trying to integrate the plugin HOT 1
- Log not working with ParameterizedTest HOT 1
- Support per-test log display for JUnit 5 instrumentation tests HOT 4
- Readme should include apply plugin for legacy syntax HOT 1
- "Expected N+1 tests, received N" caused by fun with @TestTemplate HOT 4
- Invalid test names for repeated and parametrized tests HOT 8
- Usage of ComposeExtension flags a false-positive warning in newer IDEs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-junit5.