2016-08-01 2 views
0

저는 Gradle을 사용하여 음파 탐지기를 통해 코드를 분석해야하며 처리 할 수없는 이상한 문제가 있습니다. 나는 다음과 같은 프로젝트 구조소나가 통합 테스트를 건너 뜁니다

-java 
    |-src 
    |-main 
    |-test 
    |-integration-test 

이 내가/SRC/통합 테스트에 sonar.test 속성을 변경하는 경우 소나는 기본 및 통합 테스트 디렉토리 만 테스트 디렉토리를 분석,하지만 난 함께이 두 개의 디렉토리를 분석 할 나는 그것을 실제로하는 방법을 모른다. 아래에는 gradle.build 파일에서 내 sonarqube 작업 속성이 있습니다.

sonarqube { 
    properties { 
     property "sonar.projectName", "projectName" 
     property "sonar.projectKey", "org.sonarqube:projectName" 
     property "sonar.host.url", "http://sonar.doesntmetter" 
     property "sonar.java.coveragePlugin", "jacoco" 
     property "sonar.junit.reportsPath", "build/test-results/test" 
     property "sonar.jacoco.reportPath", "build/jacoco/test.exec" 
     property "sonar.jacoco.itReportPath", "build/jacoco/integrationTest.exec" 
    property "sonar.login", "admin" 
    property "sonar.password", "admin" 
    } 
} 

내가 눈치 것은 내가 Gradle을 빌드를 실행할 때 integrationTest.exec와의/구축/jacoco/디렉토리 test.exec,하지만 난 재산 sonar.test 기본적으로 Gradle을 sonarqube을 실행할 경우이 것이있을 것 test.exec 만하고 다른 손에서 sonar.test =/src/integration-test로 gradle sonarqube를 실행하면 test.exec와 integrationTest.exec가 모두 존재하게됩니다.

단위 및 통합 테스트를 한 번에 분석하는 방법을 모르십니까?

답변

0

나는 당신이 당신의 Gradle을이를 추가 할 수 있습니다 생각 :

sonarqube { 
    properties { 
     properties["sonar.sources"] += sourceSets.custom.allSource.srcDirs 
     properties["sonar.tests"] += sourceSets.integTest.allSource.srcDirs 
    } 
} 

그냥 더 많은 테스트/소스를 추가 할 +=를 사용합니다. 자세한 정보 및 예는 here입니다.

편집 :

보고서 경로도 추가하십시오. 속성의 이름은 다음과 같습니다

sonar.surefire.reportsPath - test.testResultsDir (디렉토리가 존재하는 경우)

sonar.junit.reportsPath - test.testResultsDir (디렉토리가 존재하는 경우)

편집 :

난 당신의 코드를 다시 작성하고 한 줄에 테스트를위한 소스를 설정, 당신의 구조를 확인

sonarqube { 
    properties { 
     property "sonar.projectName", "projectName" 
     property "sonar.projectKey", "projectKey" 
     property "sonar.host.url", "http://itsprettyprivate" 
     property "sonar.java.coveragePlugin", "jacoco" 
     // Or add it via += to properties, it is up to you ;) 
     property "sonar.sources", "src/java,src/test,src/integration-test" 
     //Tells SonarQube where the unit tests execution reports are 
     property "sonar.junit.reportsPath", "build/test-results/test" 
     //Tells SonarQube where the unit tests code coverage report is 
     property "sonar.jacoco.reportPath", "build/jacoco/test.exec" 
     //Tells SonarQube where the integration tests code coverage report is 
     property "sonar.jacoco.itReportPath", "build/jacoco/integrationTest.exec" 
     property "sonar.login", "admin" 
     property "sonar.password", "password" 
    } 
} 
+0

불행히도 도움이되지 않습니다. 단위 테스트에 대한 통계 만 있습니다. –

+0

보고서가 누락되었지만 테스트가 실행되었습니다. 그럼 당신은 reportPath에 대한 속성을 더 추가해야합니다 :'sonar.surefire.reportsPath' 'sonar.junit.reportsPath' – Hrabosch

+0

실제로 통합 테스트가 실행되지 않습니다 –

관련 문제