kotlinx-kover icon indicating copy to clipboard operation
kotlinx-kover copied to clipboard

Get code coverage from running process

Open michael-arndt-gcx opened this issue 3 years ago • 4 comments

With jacoco it's possible to use a java agent to get coverage at runtime. This enables collecting coverage during integration and end-to-end tests. I don't see an option like this with kover yet?

More precisely we're building OCI images (using build packs / bootBuildImage) and then run tests against a running container.

michael-arndt-gcx avatar Aug 09 '22 12:08 michael-arndt-gcx

Hi, do you mean to get statistics via network ports?

shanshin avatar Aug 09 '22 19:08 shanshin

You can instrument the system-under-test with a java agent (not sure how multiplatform support can be achieved). The java agent then provides execution data either over a TCP connection, or by dumping the execution data to the filesystem, which can then be aggregated with data from other sources. (For instance unit test coverage collected in usual way).

Kantis avatar Jan 17 '23 13:01 Kantis

@Kantis can you please add some more details/example on how to instrument a JVM? I have an IntelliJ plugin with ui test that includes 2 processes- 1 the ide to test 2 the ui test I would like to collect the coverage for the this scenario

Thanks

Jonatha1983 avatar Nov 28 '23 19:11 Jonatha1983

@Jonatha1983 you would add -javaagent:$jacocoJarPath=destfile=$pathWhereYouWantCoverageData/jacoco-it.exec,includes=com.mypackages.*" to the arguments which you start the java process under test with. It all depends a bit on the rest of the infrastructure of your project.

@shanshin feel free to remove this comment if it derails the discussion too much.

Kantis avatar Nov 28 '23 20:11 Kantis