https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

sendoav

02/21/2020, 7:57 AM
Anyone has a working jacoco sample file?
e

Erik Christensen

02/21/2020, 3:32 PM
A task called "jacocoTestReport" is automatically created by the jacoco plugin, which you may want to consider modifying instead of creating a new one. It doesn't have a dependency on running the tests -- it's expected that you do that first though. If I recall correctly, there's some rationale as to why it shouldn't be a dependency (could be something that's tripping you up). Also double check the name of the .exec file that's generated. I have a working example here: https://github.com/erikc5000/island-time/blob/master/buildSrc/src/main/kotlin/multiplatform-library.gradle.kts
s

sendoav

02/27/2020, 2:37 PM
Thanks Erik! Finally managed to get it working. Do you know if it is possible to see the tested methods marked down with green/red bars within AS when using Jacoco? Or that functionality works only for IntelliJ code coverage?
e

Erik Christensen

02/27/2020, 3:58 PM
Personally, I've only looked at the report in a web browser. Not sure if it works right in AS or not.
s

sendoav

02/28/2020, 12:37 PM
Ok thanks Erik 🙂
c

Carter

08/09/2020, 2:42 PM
Following up on this thread, I was able to get this example working for a library multiplatform module after adding the
java-library
gradle plugin. The problem with this is that my app module which consumes the libraries fails to build. My workaround for now is a command line flag to turn coverage on and using a -x arg to prevent building the app module. But is there a less janky way to do this?
I noticed that Erik’s example uses a plugin for
published-library
but I can’t seem to find what that is.
e

Erik Christensen

08/11/2020, 8:44 PM
That's a "precompiled script plugin". It's a Gradle script in buildSrc that can be applied to any project in the build to setup things or add tasks.
c

Carter

08/11/2020, 8:45 PM
Ah, I see.
I actually ran into one other problem.
My tests aren’t able to find some of my classes, so a lot of them throw class not found exceptions.
Those exceptions were being masked by gradle caching, which is why they didn’t get noticed sooner.
So it seems like there’s an issue with running all the tests on the JVM and running common and jvm tests.
Is that working for you
?
e

Erik Christensen

08/11/2020, 8:48 PM
That's usually caused by renamed classes that can still be found in the build directory. Deleting it will fix that.
c

Carter

08/15/2020, 3:04 PM
At what point are you deleting it? For me, the issue reproduces consistently if I run ./gradlew clean before ./gradlew check
So after a lot of troubleshooting, it looks like my issue is being triggered by dependencies on other modules within my project. When enabling Jacoco, it looks like it loses track of multiplatform
project
dependencies (but is OK with non-project dependencies), and that is causing the exceptions when running the tests. Ideas on how I might resolve that?
No, I spoke too soon and that’s not actually it. Continuing to troubleshoot.
The actual culprit is inline methods. They are causing the java.lang.NoClassDefFoundError.
10 Views