[英]How to Export JUNIT Test Result as XML in Spring Boot Application for SonarQube Purpose?
I already search on Google and Stackoverflow about this Question, and don't have any answer that related to this kind of question. 我已经在Google和Stackoverflow上搜索了有关此问题的信息,但没有与此类问题相关的任何答案。
So the problem is, I have a Project with Spring MVC. 所以问题是,我有一个带有Spring MVC的项目。 I create simple test like this:
我创建像这样的简单测试:
@Autowired
private UserLogicService logicService;;
@Test
public void helloTrue(){
//return should be 1
assertThat(logicService.hello(), is(1)); //test return success
}
@Test
public void helloFalse(){
//return should be 1
assertThat(logicService.hello(), is(2)); //test return fail
}
And then I need to export it to XML because I read the documentation of SonarQube, HERE , The tests execution reports have to comply to the JUnit XML format. 然后,我需要将其导出为XML,因为我阅读了SonarQube的文档HERE ,测试执行报告必须符合JUnit XML格式。
I use SonarScanner third party to Scan my Spring Project. 我使用SonarScanner第三方扫描我的Spring项目。 So I need to Export my JUnit result as XML and scan it with SonarScanner.
因此,我需要将JUnit结果导出为XML并使用SonarScanner对其进行扫描。
Is there any Setting to Automatically export JUnit Test Result to a folder as XML file? 是否有任何设置可以将JUnit测试结果自动导出为XML文件的文件夹?
I would recommend using a build tool like maven or gradle. 我建议使用诸如maven或gradle之类的构建工具。 There you can find plugins which do the trick for you.
在这里,您可以找到为您解决问题的插件。
Execute your tests with JaCoCo or Cobertura, then provide the paths to the coverage reports with either sonar.jacoco.reportPath
or sonar.cobertura.reportPath
as described in the docs . 使用JaCoCo或Cobertura执行测试,然后使用docs中所述的
sonar.jacoco.reportPath
或sonar.cobertura.reportPath
提供覆盖报告的路径。
You only need to translate to an XML format if your test engine doesn't provide a format that the language analyzer already understands. 如果您的测试引擎没有提供语言分析器已经可以理解的格式,则仅需要转换为XML格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.