Jacoco在命令行中报告 [英] Jacoco report in command line
问题描述
我必须编写.sh启动一个覆盖Jacoco的UI应用程序。退出时,必须生成一个jacoco报告。
I have to write a .sh launching an UI application covered with Jacoco. On exit, a jacoco report must be generated.
我无法使用这个简单的命令生成jacoco.exec:
I'm not able to generate the jacoco.exec with this simple command :
java -jar ../binaries/editor.debug/application.jar -javaagent:/atgl/products/jacoco/0.6.3/lib/jacocoagent.jar=destfile=jacoco.exec
命令的第一部分工作正常并启动程序,但是 - javaagent选项不生成报告,程序也不启动。
如果我做了语法错误,它的行为完全相同。
The first part of the command works fine and launch the program, but the -javaagent option doesn't generate report and the program doesn't launch. If I do a syntax error it's exactly the same behavior.
我的命令出了什么问题?
What's wrong with my command ?
其次,此命令创建一个.exec文件。如何在命令行中生成.html报告?
Secondly, this command create a .exec file. How can I generate a .html report in command line ?
推荐答案
问题在于-javaagent选项的位置。它需要处于第一位,如下所示:
The problem was the position of the -javaagent option. It needed to be in first position, like this :
java -javaagent:/atgl/products/jacoco/0.6.3/lib/jacocoagent.jar=destfile=jacoco.exec -jar ../binaries/editor.debug/application.jar
然后正如Godin所说,在命令行中生成报告是不可能的。我使用规则 do_jacoco_reports 创建了一个ant文件 exectoreport.xml 。该规则由脚本exectoreport.sh启动,该脚本必须在应用程序自然退出后调用。
Then as Godin said, it's not possible to generate report in command line. I created an ant file exectoreport.xml with a rule do_jacoco_reports. The rule is launched by a script exectoreport.sh, that must be called after the natural exit of the application.
这篇关于Jacoco在命令行中报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!