Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Support Code-Coverage (preferably Jacoco) for integration tests #1434

Open
tonit opened this issue Jul 8, 2016 · 6 comments
Open

Support Code-Coverage (preferably Jacoco) for integration tests #1434

tonit opened this issue Jul 8, 2016 · 6 comments
Milestone

Comments

@tonit
Copy link

tonit commented Jul 8, 2016

Integration tests in bndtools use a custom test launcher. Thats why they are not part of test coverage (coverage always 0%).
Guess its only a matter of passing jacoco preprocessing code to the underlying test process. I have not looked deeply into the launcher code. Maybe there is already a way to do it but i do not find the right documentation for it?

@bjhargrave bjhargrave added this to the Someday milestone Jul 22, 2016
@bjhargrave
Copy link
Member

Please make a PR, thanks.

@bjhargrave
Copy link
Member

Also, have you tried the jacoco gradle plugin in your gradle build?

@tonit
Copy link
Author

tonit commented Jul 22, 2016

Yes we did. Integrationtests do not contribute to the code coverage measured by jacoco.
Detailed description: We have regular unit tests and integration tests. The Jacoco Report shows unit tests as well as integration tests. But only the unit tests contribute to the coverage. Both test types are executed.
Without having looked at the code yet, i guess integration tests run in their own jvm?

@bjhargrave
Copy link
Member

i guess integration tests run in their own jvm?

Yes, a new VM is launched to run the framework, test bundles and any other -runbundles.

@jwausle
Copy link

jwausle commented Sep 14, 2017

It seems that -javaagent: jacoco.jar... instruction is wrong evaluated while osgi test execution.

  • the calculated java cmd looks like java -javaagent:biz.aQute.launcher-3.4.0.jar -cp ...:biz.aQute.launcher-3.4.0.jar ...
  • the ./bnd.bnd "-javaagent:..." instruction value is ignored

I prepared a sample project

git clone https://github.com/jwausle/bndtools-testcase-fragment.git --jacoco-support
cd bndtools-testcase-fragment
sh gradlew clean build

@bjhargrave
Copy link
Member

bjhargrave commented Sep 15, 2017

You are using the -javaagent Bnd instruction incorrectly. The documentation was wrong and I have made a PR to fix it.

You need to put jacoco.jar (if that is the agent jar) on the -runpath and then have-javaagent: true. Then the launcher will inspect the classpath elements and create -javaagent: Java arguments for all the jars having a Premain-Class manifest header.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants