声纳单位测试覆盖百分比未正确显示

时间:2012-11-21 14:47:49

标签: maven sonarqube sonar-runner

我刚刚对我的项目实施了Sonar分析。它有javaSpringHibernateGWT环境。我使用Spring-Junit 4为业务层编写了一些单元测试用例。当我尝试执行这些测试用例时,它在Eclipsemaven install以及声纳报告中完美运行,如下所示:

问题是,在声纳报告单元测试覆盖率仍为 0.0%,尽管已成功执行了11个测试用例。我已使用命令mvn sonar:sonar

独立声纳服务器上生成此报告

示例测试用例

@RunWith(value=SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:test-context.xml"})
@TransactionConfiguration(defaultRollback=true)
@Transactional
public class ThresholdServicesImplTest {

    @Autowired
    private IThresholdServices thresholdServices;


        @Test
        public void testSomemethods(){
        //testing and validating the methods.
         }

}

Sonar屏幕截图(业务层代码)

screen shot of sonar for business layer module alone

从上面的截图中,成功执行了11个测试用例,但这对单元测试覆盖率没有任何影响。

请提供解决此问题的建议。

注意:

  1. 对于其他层(数据和服务层),单元测试覆盖率为 按预期显示。
  2. 此商家的总行数 图层是2,995,我将在测试中覆盖至少500个LOC 覆盖率,因此测试覆盖率的百分比不可忽略 对于这种情况。

0 个答案:

没有答案