In this thread I will be teasing out Compose for D...
# compose-desktop
p
In this thread I will be teasing out Compose for Desktop with code coverage. The strategy is to let IntelliJ generate the Hello, Desktop basic app and then add infrastructure to eventually get a sensible code coverage report for this trivial app.
The IntelliJ version information is: IntelliJ IDEA 2021.3.1 (Ultimate Edition) Build #IU-213.6461.79, built on December 28, 2021 Licensed to Argus / Paul Reilly Subscription is active until October 1, 2022. For non-commercial open source development only. Runtime version: 11.0.13+7-b1751.21 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 12.2.1 GC: G1 Young Generation, G1 Old Generation Memory: 2048M Cores: 10 Non-Bundled Plugins: com.intellij.nativeDebug (213.6461.6) org.jetbrains.kotlin (213-1.6.10-release-944-IJ6461.79) Statistic (4.1.7) Kotlin: 213-1.6.10-release-944-IJ6461.79
Using defaults, the app builds and runs without a hitch and generates the expected output (after clicking on the button):
Next step is to add the Kover plugin to the build script:
id("org.jetbrains.kotlinx.kover") version "0.4.2"
A Gradle run of the clean and build tasks is successful at doing nothing. Next step is to add a Kover configuration, borrowing from another project so that the kover configuration is:
kover {
isEnabled = true
coverageEngine.set(kotlinx.kover.api.CoverageEngine.INTELLIJ)
intellijEngineVersion.set("1.0.622")
generateReportOnCheck.set(true)
}
Another clean, build Gradle run still is successful at doing nothing. Hmmm. that is a surprise that nothing different happened ... my expectation was that kover would run and complain that nothing was covered. Next step is to figure out why there is no report and why Gradle thinks that the report is up-to-date. Hmmm. If you've been following along and have some idea about what is wrong, do tell. I'll be back when I figure out the answers to those two questions.
Ah, that was easy. There were no tests. Adding a simple test to do nothing works and a report is generated. I'll take a break here to go generate a YouTrack issue that IntelliJ ought to generate basic, really simple, tests for Compose Multiplatform.
Next, I added a simple test and created a Gitlab project for this thread. As you can see from the attached screen shot, the test passes but also throws an exception. I am still struggling trying to explain the exception in an actionable way. Looks very much like a Compose Multiplatform bug. @olonho or @Igor Demin would you agree?
i
I have this error on Compose 1.0.0, but don’t have on Compose 1.1.0
p
Good to know. It also raises the questions: should a bug report be filed on 1.0.0 or should 1.1.0 be preferred. My preference is the latter.
i
1.1.0 is released, so no need in bug report
p
Preferring the Compose plugin version 1.1.0 actually generates a valid coverage report. Hallelujah! But to get there, the following build and code changes were required (and have been pushed to the Gitlab repo mentioned above):
🎉 1
And that's a successful wrap for this thread.