我正在尝试为我的项目生成 SonarQube 报告,但是尽管使用“JobLauncherTestUtils”执行了完整的工作流程,但我得到了0%的代码覆盖率。我尝试了很多方法,比如升级 Jacoco 版本等,但没有任何效果。
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = MainApplication.class)
@EnableAutoConfiguration
@ContextConfiguration(locations = {"classpath:test-context.xml"})
public class MyTest {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
@Test
public void Test1(){
JobExecution jobExecution = jobLauncherTestUtils.launchJob(defaultJobParameters());
Assert.assertEquals("COMPLETED", jobExecution.getExitStatus().getExitCode());
}
}