How to generate Spock reports with Eclipse

965 Views Asked by At

How do I generate html reports using the spock reports extension (https://github.com/renatoathaydes/spock-reports). I've added the dependency to my build.gradle file which, as far as I can tell, is the only thing I need to do. But when I run my tests on Eclipse I can't find any report appearing anywhere.

Here's my build.gradle file, spock reports dependency are at the end.

apply plugin: 'java-library'
apply plugin: 'groovy'

repositories {
    jcenter()
}

dependencies {
    api 'org.apache.commons:commons-math3:3.6.1'

    implementation 'com.google.guava:guava:22.0'

    testImplementation 'org.codehaus.groovy:groovy-all:2.4.11'

    testImplementation 'org.spockframework:spock-core:1.0-groovy-2.4'
    testImplementation 'junit:junit:4.12'

    testCompile( 'com.athaydes:spock-reports:1.3.1' ) {
        transitive = false // this avoids affecting your version of Groovy/Spock
    }
    testCompile 'org.slf4j:slf4j-api:1.7.13'
    testCompile 'org.slf4j:slf4j-simple:1.7.13'
}

EDIT: The build.gradle file is wrong.

I generated the build with "gradle init --type java-library --test-framework spock" which worked fine, I added some groovy classes and could run tests successfully on eclipse, but it gave me a "Cannot infer Groovy class path because no Groovy Jar was found on class path [...]" error when I tried to use gradle.build.

I changed the Groovy dependency from "testImplementatiuon" to "compile". It made it so that the project could compile and run tests from the command line. This also generated spock reports.

Running tests on eclipse still doesn't generate test reports.

I build a new project from the command line with this build.gradle file:

apply plugin: 'groovy'
apply plugin: 'java-library'

repositories { jcenter() }

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.4.11'
    testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
    testCompile( 'com.athaydes:spock-reports:1.3.1' ) {
        transitive = false // this avoids affecting your version of Groovy/Spock
    }
    testCompile 'org.slf4j:slf4j-api:1.7.13'
    testCompile 'org.slf4j:slf4j-simple:1.7.13'
}

And copied the same groovy files on it. Then imported the project to eclipse. This one works when I run tests from eclipse (it generates spock reports). I still don't know what the problem was exactly but I guess my issue is solved.

0

There are 0 best solutions below