Q:

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.
So the problem is, I have a Project with 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.
I use SonarScanner third party to Scan my Spring Project. So I need to Export my JUnit result as XML and scan it with SonarScanner. 
Is there any Setting to Automatically export JUnit Test Result to a folder as XML file?

A:

I would recommend using a build tool like maven or gradle. There you can find plugins which do the trick for you.
Gradle plugins

