Sonarqube test case rule does not take @Test annotation into account

我的未来我决定 提交于 2019-12-24 14:18:35

问题


Sonarqube generates issues as

TestCases should contain tests

regarding that test classes does not have any tests inside but there are methods marked with @Test annotation and classes annotated with @RunWith(SpringJunit4ClassRunner.class).

I have no problem running TestSuites and importing unit test and coverage reports into sonarqube. I checked sonarqube source code and it should find annotations but unfortunately it does not. Rule id for the mentioned issue is S2187.

Is there a configuration for this rule to find annotated methods or is a known issue?

Edit - config:

sonar.projectKey=x
sonar.projectName=x
sonar.projectVersion=1.0 
sonar.modules=a,b,c
a.sonar.projectBaseDir=modules/a
b.sonar.projectBaseDir=modules/b
c.sonar.projectBaseDir=modules/c
sonar.sources=src
sonar.tests=test
sonar.java.binaries=../**/classes/production,../**/classes/test
sonar.java.libraries=../../libraries/repository
sonar.junit.reportsPath=junit/
sonar.java.coveragePlugin=jacoco
sonar.jacoco.reporthPath=coverage/jacoco.exec
sonar.language=java
sonar.sourceEncoding=UTF-8

回答1:


Issue has been fixed by correctly setting sonar.java.test.libraries/binaries attributes as answered in https://stackoverflow.com/a/32197912/343806. They were not not in the runner configuration and after adding raised issues in sonarqube results marked as fixed.



来源:https://stackoverflow.com/questions/30860378/sonarqube-test-case-rule-does-not-take-test-annotation-into-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!