Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make jacoco work with integration tests #459

Open
jonesbusy opened this issue Dec 15, 2024 · 5 comments
Open

Make jacoco work with integration tests #459

jonesbusy opened this issue Dec 15, 2024 · 5 comments
Labels
enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted good first issue Good for newcomers

Comments

@jonesbusy
Copy link
Collaborator

jonesbusy commented Dec 15, 2024

What feature do you want to see added?

Right now coverage is only computed on unit tests

When we run integration tests with failsafe and 'java -jar..' we should add the argLine to the execution and make sure the execution is merged with previous jacoco execution.

Possible code change on CommandLineIT if we need to pass the jacoco argLine ?

Properties properties = new Properties();
String changeList = System.getProperty("set.changelist");
if (changeList != null) {
    properties.put("set.changelist", "true");
}
properties.put("exec.executable", javaHome.resolve("bin/java").toString());
properties.put("test.cliArgs", args);
request.setProperties(properties);
``

### Upstream changes

No code change expected, and maven config
@jonesbusy jonesbusy added the enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Dec 15, 2024
@jonesbusy jonesbusy added the good first issue Good for newcomers label Dec 28, 2024
@jonesbusy
Copy link
Collaborator Author

Good first issue if someone interested by Maven config and jacoco coverage

@jonesbusy
Copy link
Collaborator Author

@jonesbusy
Copy link
Collaborator Author

Dis some quick test without maven

curl -O https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/0.8.12/org.jacoco.cli-0.8.12-nodeps.jar 
curl -O https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.8.12/org.jacoco.agent-0.8.12-runtime.jar

# Run with agent
java '-javaagent:org.jacoco.agent-0.8.12-runtime.jar=port=6300,address=0.0.0.0,destfile=jacoco.exec,includes=io.jenkins.tools.pluginmodernizer.*,append=true,output=tcpserver' -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar build-metadata --plugins echarts-api --debug

# On other shell
java -jar org.jacoco.cli-0.8.12-nodeps.jar dump --address localhost --port 6300 --destfile jacoco.exec --reset
java -jar org.jacoco.cli-0.8.12-nodeps.jar report jacoco.exec --classfiles plugin-modernizer-core/target/classes --sourcefiles plugin-modernizer-core/src/main/java --html coverage_report

Screenshot from 2024-12-28 10-58-11

Now we need to integration with failsafe, maven exec and jacoco plugin.

And merge all together with previous unit tests

@Yash-jaiswal2509
Copy link

Hi, as I was working on this. I wanted to know if I will have to also change pom.xml and pom-it.xml to integrate jacoco.

@jonesbusy
Copy link
Collaborator Author

Most likely yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants