英文:
How can I get Jacoco coverage Report per Request
问题
我正在使用 jacoco
代理通过运行以下命令生成我的 覆盖率报告,格式为 xml
文件:
java -jar <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/src/main/resources/lib/jacococli.jar report <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/target/jacoco-it.exec --classfiles <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/target/classes/com --sourcefiles src/main/java/ --xml <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/target/report.xml
这基本上会将数据写入 jacoco-it.exec
文件,并保存先前的覆盖率数据。
但我希望每次请求都进行覆盖率分析,有没有办法删除 jacoco 代理收集的先前数据?
英文:
I am using jacoco
agent to generate my coverage reports in the form of xml
files by running the command:
java -jar <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/src/main/resources/lib/jacococli.jar report <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/target/jacoco-it.exec --classfiles <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/target/classes/com --sourcefiles src/main/java/ --xml <path>/sample_projects/beta/jacoco-code-coverage/jacoco-code-coverage-example/target/report.xml
This basically writes to jacoco-it.exec
file and it saves previous coverage data as well.
But I want coverage analysis per request made, is there any way I can erase previous data collected by jacoco agent.
答案1
得分: 2
所以基本上我已经找到解决方案,只需在请求完成后重置中间件中的执行转储,按照以下顺序进行操作,我就能够获得每个请求的覆盖分析。
ExecDumpClient execDumpClient = new ExecDumpClient();
execDumpClient.setReset(true);
execDumpClient.dump("localhost", 36320);
英文:
So basically I got the solution just reset the exec dump at my middleware after the request has been made in this order I am able to get the coverage analysis per request.
ExecDumpClient execDumpClient = new ExecDumpClient();
execDumpClient.setReset(true);
execDumpClient.dump("localhost", 36320);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论