2017-01-03 46 views
2

我有测试多语言项目中使用Java(JUnit的)和Groovy(斯波克)来实现。摇篮sonarqube不承认常规测试

plugins { 
    id "org.sonarqube" version "2.2.1" 
} 

apply plugin: 'idea' 
apply plugin: 'java' 
apply plugin: 'groovy' 
apply plugin: 'jacoco' 

ext { 
    spockVersion = '1.1-groovy-2.4-rc-3' 
    groovyVersion = '2.4.7' 
} 

group = "at.softwarecraftsmen.poc" 
version = "1.0.0-SNAPSHOT" 

repositories { 
    mavenCentral() 
} 

dependencies { 
    testCompile "junit:junit-dep:4.11" 

    testCompile "org.codehaus.groovy:groovy-all:$groovyVersion" 
    testCompile "org.spockframework:spock-core:$spockVersion" 
} 

jacoco { 
    toolVersion = "0.7.8+" 
} 

sonarqube { 
    properties { 
     //property 'sonar.tests', ["src/test/groovy", "src/test/java"] 
     properties['sonar.tests'] += ["src/test/groovy"] 
    } 
} 

当运行sonarqube任务时,它成功运行,但报告Resource not found: at.softwarecraftsmen.poc.sonar.domain.DomainTesteeSpec。这是使用Groovy一个斯波克测试。

以下是完整的日志输出从摇篮产生:

$ ./gradlew clean jacoco sonarqube 
:clean 
:compileJava 
:compileGroovy UP-TO-DATE 
:processResources UP-TO-DATE 
:classes 
:compileTestJava 
:compileTestGroovy 
:processTestResources UP-TO-DATE 
:testClasses 
:test 
objc[4573]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined. 
:jacocoTestReport 
:sonarqube 
Resource not found: at.softwarecraftsmen.poc.sonar.domain.DomainTesteeSpec 
CodeNarc completed: (p1=0; p2=0; p3=0) 941ms 
Resource not found: at.softwarecraftsmen.poc.sonar.domain.DomainTesteeUnitTest 
File not found: at/softwarecraftsmen/poc/sonar/domain/DomainTestee.java 
Coverage information was not collected. Perhaps you forget to include debug information into compiled classes? 
File not found: at/softwarecraftsmen/poc/sonar/domain/DomainTestee.java 
Coverage information was not collected. Perhaps you forget to include debug information into compiled classes? 
BUILD SUCCESSFUL 

添加properties['sonar.tests'] += ["src/test/groovy"]不能解决问题,从src/test/java只测试正确的报道。

------------------------------------------------------------ 
Gradle 3.3 
------------------------------------------------------------ 

Build time: 2017-01-03 15:31:04 UTC 
Revision:  075893a3d0798c0c1f322899b41ceca82e4e134b 

Groovy:  2.4.7 
Ant:   Apache Ant(TM) version 1.9.6 compiled on June 29 2015 
JVM:   1.8.0_71 (Oracle Corporation 25.71-b15) 
OS:   Mac OS X 10.11.6 x86_64 
+0

相关:http://stackoverflow.com/questions/41886878/integrate-spocks-test-with-sonar – kazanaki

回答

0

确保您已经安装了声纳Groovy插件如下解释:

Integrate Spock's test with Sonar

您需要在声纳实例管理员权限做到这一点。

+0

我有同样的问题。作为链接的问题提到添加插件后,我看到出现在SonarQube测试。然而,覆盖数据不考虑斯波克测试。 –