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

tvede

02/09/2019, 4:15 PM
Hello everyone; so a quick question; is there any way that IDEA can provide Unit code coverage for a multiplatform library ? it seems like any way i try run with coverage (from idea) results in it never actually taking the common library code into account..
a

addamsson

02/09/2019, 4:26 PM
I'd also like to know this. No coverage for me either. I think IDEA uses some Java library for coverate which can't understand common code but this is just a guess.
i

ian.shaun.thomas

02/09/2019, 4:49 PM
The issue is how would you want this reported? You can't actually write unit tests against common code given common code can't be run anywhere. Via compilation the common code is inherently testable and obviously unit tests in the common modules are copied up to the compiled targets for execution and from there we can gather code coverage. For example, I got unified code coverage working for the JVM and Android by mashing their Jacoco reports together and their reports include code from module. https://codecov.io/gh/ToxicBakery/Arbor/branch/feature%2Funified-code-coverage
and this is how you can merge classes/reports together which is the typical way of doing it from a jacoco perspective. I have not figured out how to get instanbul to run properly for js code coverage and every other platform possibility adds additional coverage problems. In the end though, tools like codecov are what we really need to map out the coverage into something understandable. I'm not sure how jetbrains would be able to support bringing that data back into IDEA for giving a direct approach to coverage like we are used to with JVM/android coverage reports in the editor/coverage window pane https://github.com/ToxicBakery/Arbor/blob/master/common/build.gradle#L92
👍 1
t

tvede

02/09/2019, 4:54 PM
@ian.shaun.thomas That is totally fair, but even in that regard, the coverage tool should somehow be able to extract that knowledge from the common code ( eg running coverage on JVM, native or even js ) should all contain the common code, (+ common tests) thus no matter what target you should be able to know the coverage of the common code; the problem with jacoco is that inline functions is somewhat not done, (see https://github.com/jacoco/jacoco/issues/654 ) If you try and run a JVM taget from a MPP project you can see it "tries" to display some sort of coverage for common code, but its kinda "1 classs" akk not really mapped out; so i was currious if it was there, but required some more work ,or simply put, not fully implemented;
👍 1
a

addamsson

02/09/2019, 6:22 PM
I think the problem here is that if I have common tests
coverage doesn't work from IDEA out of the box
I don't really want to set up things I just want to check if I missed something
another problem is that you can't run common tests from IDEA either, there is no green triangle button next to them
i

ian.shaun.thomas

02/09/2019, 6:23 PM
completely understandable, for at least jvm and android modules, hopefully they can support that better in the future. I would also like to see them better support at least JS as it's currently pretty annoying at best.
a

addamsson

02/09/2019, 6:24 PM
I think Kotlin is going to need its own coverage tool written in Kotlin common at some point
i

ian.shaun.thomas

02/09/2019, 6:24 PM
that would be fantastic
a

addamsson

02/09/2019, 6:25 PM
yep
I think we're already moving in that direction
now we can implement basically anything on top of the Kotlin common stdlib
4 Views