renatoathaydes/spock-reports

Empty Markdown Files

Closed this issue ยท 12 comments

Here is my properties-file:

# Name of the implementation class of the report creator
# Currently supported classes are:
#   1. com.athaydes.spockframework.report.internal.HtmlReportCreator
#   2. com.athaydes.spockframework.report.template.TemplateReportCreator
com.athaydes.spockframework.report.IReportCreator=com.athaydes.spockframework.report.template.TemplateReportCreator

# Set properties of the report creator
# For the HtmlReportCreator, the only properties available are
# (the location of the css files is relative to the classpath):
# com.athaydes.spockframework.report.internal.HtmlReportCreator.featureReportCss=spock-feature-report.css
# com.athaydes.spockframework.report.internal.HtmlReportCreator.summaryReportCss=spock-summary-report.css
# exclude Specs Table of Contents
# com.athaydes.spockframework.report.internal.HtmlReportCreator.excludeToc=false

# Output directory (where the spock reports will be created) - relative to working directory
com.athaydes.spockframework.report.outputDir=build/spock-reports-ad

# If set to true, hides blocks which do not have any description
com.athaydes.spockframework.report.hideEmptyBlocks=false

# Set properties of the report creator
com.athaydes.spockframework.report.template.TemplateReportCreator.specTemplateFile=/spockreporttemplate/spec-template.ad
com.athaydes.spockframework.report.template.TemplateReportCreator.reportFileExtension=ad
com.athaydes.spockframework.report.template.TemplateReportCreator.summaryTemplateFile=/spockreporttemplate/summary-template.ad
com.athaydes.spockframework.report.template.TemplateReportCreator.summaryFileName=summary.ad

In the specified folder (spock-reports-ad), only empty Markdown-Files are created. Did I do something wrong?

Edit: I checked out my "test-results" folder where details for the tests are saved as XML and they provide the following error message:

Unexpected error creatingreport
java.lang.NullPointerException

Please follow the instructions to enable logging, set log level to DEBUG, run your tests again, and see if you get more information.

Also, I just remembered there's a problem with templates in the latest version, if you downgrade to version 1.2.9 it should work fine.

The problem was fixed but I haven't released it yet, unfortunately.

I have just released spock-reports version 1.2.11 which should fix this issue! Please try it out and let me know how it goes.

Thanks, you're awesome :) I'll try it out and share my experience with you.

Ok, on the WARN level I now have this:

WARN com.athaydes.spockframework.report.template.TemplateReportCreator - Unexpected error creating report
groovy.lang.MissingPropertyException: No such property: grails for class: groovy.lang.Binding

And on DEBUG I noticed this:

11:47:03.249 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class groovy/lang/Closure from groovy-all-2.4.5.jar
11:47:03.317 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class groovy/lang/GroovyObjectSupport from groovy-all-2.4.5.jar
11:47:03.318 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-scan : failed to scan parent class java/lang/Object, could not find the class file
11:47:03.327 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class geb/Module from geb-core-0.13.1.jar
11:47:03.329 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-scan : failed to scan parent class java/lang/Object, could not find the class file
11:47:03.330 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class geb/spock/GebReportingSpec from geb-spock-0.13.1.jar
11:47:03.332 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class geb/spock/GebSpec from geb-spock-0.13.1.jar
11:47:03.347 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class spock/lang/Specification from spock-core-1.0-groovy-2.4.jar
11:47:03.375 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpIncomingConnector] Listening on [da6ffdd4-6a47-48d1-bf50-0ba93d53c044 port:60676, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]].
11:47:03.375 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class geb/Page from geb-core-0.13.1.jar
11:47:03.376 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-scan : failed to scan parent class java/lang/Object, could not find the class file

My build-script looks like this ATM:

import org.apache.tools.ant.taskdefs.condition.Os

defaultTasks 'clean', 'test', 'convertJsonReport', 'asciidoc'

ext {
    drivers = ["firefox", "chrome"]

    ext {
        groovyVersion = '2.4.5'
        gebVersion = '0.13.1'
        seleniumVersion = '2.53.0'
        chromeDriverVersion = '2.19'
    }
}

apply plugin: "groovy"
apply from: "gradle/idea.gradle"
apply from: "gradle/osSpecificDownloads.gradle"
apply from: "gradle/filmStrip.gradle"

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    testCompile "org.gebish:geb-spock:$gebVersion"
    testCompile("org.spockframework:spock-core:1.0-groovy-2.4") {
        exclude group: "org.codehaus.groovy"
    }
    testCompile "org.codehaus.groovy:groovy-all:$groovyVersion"
    testCompile "org.gebish:geb-junit4:$gebVersion"

    testCompile ("com.athaydes:spock-reports:1.2.11") {
        transitive = false
    }

    testCompile "org.slf4j:slf4j-api:1.7.13"
    testCompile "org.slf4j:slf4j-simple:1.7.13"

    testCompile "org.asciidoctor:asciidoctor-gradle-plugin:1.5.3"

    testCompile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
}

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }

    dependencies {
        classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.3"
        classpath 'com.lookout:jruby-gradle-plugin:2.0.+'
    }
}

drivers.each { driver ->
    task "${driver}Test"(type: Test) {
        reports {
            html.destination = reporting.file("$name/tests")
            junitXml.destination = file("$buildDir/test-results/$name")
        }

        outputs.upToDateWhen { false }  // Always run tests

        systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
        systemProperty "geb.env", driver

    }
}

chromeTest {
    dependsOn unzipChromeDriver

    def chromedriverFilename = Os.isFamily(Os.FAMILY_WINDOWS) ? "chromedriver.exe" : "chromedriver"
    systemProperty "webdriver.chrome.driver", new File(unzipChromeDriver.outputs.files.singleFile, chromedriverFilename).absolutePath
}

test {
    dependsOn drivers.collect { tasks["${it}Test"] }
    enabled = false
    ignoreFailures = true
    systemProperties "geb.build.reportsDir": "$reportsDir/geb"
    outputs.upToDateWhen { false }  // Always run tests

    testLogging {
        showStandardStreams = true
    }
}

apply plugin: "org.asciidoctor.convert"
apply plugin: "org.asciidoctor.gradle.asciidoctor"

asciidoctor {
    outputs.upToDateWhen { false }  // Always run
    outputDir = file("$buildDir/docs")
    println file("$buildDir/docs")
    sourceDir = file("$buildDir/spock-reports-ad")
    sources {
        include "summary.ad"
    }
    attributes 'toc' : 'left',
            'icons' : 'font'
    logDocuments = true
}

apply from: "gradle/ci.gradle"

And I have not changed my properties file in META-INF/services.

Looks like the root cause of the problem is this:

WARN com.athaydes.spockframework.report.template.TemplateReportCreator - Unexpected error creating report
groovy.lang.MissingPropertyException: No such property: grails for class: groovy.lang.Binding

This log message should be followed by the stacktrace. Do you have the stacktrace?

I don't think this error is coming from spock-reports code because the missing property grails is never mentioned in spock-reports code.

I know that Grails users need some special setup to get spock-reports to find the correct templates and resources, hope you saw it on the README page.

Notice the links to Grails-specific setup, which were written by @rdmueller... maybe he has faced this issue before as well, I know he is also using Grails and asciidoctor!?

This is strange. I got rid of the "grails for class" but the error is still there and stacktrace is not very helpful. Here is the complete Output for the full-stacktrace:

C:\Users\UserXy\Documents\sample-testing>gradle --full-stacktrace
FilmStrip: monkey patch for geb.report.Reporter
C:\Users\UserXy\Documents\sample-testing\build\docs
:clean
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:compileTestGroovy
:processTestResources
:testClasses
:downloadChromeDriver
:unzipChromeDriver
:chromeTest
entering summary-template
:firefoxTest
entering summary-template
:test SKIPPED
> Building 93% > :asciidoctorio/console not supported; tty will not be manipulated
:asciidoctor
Converting C:\Users\UserXy\Documents\sample-testing\build\spock-reports-ad\summary.ad

BUILD SUCCESSFUL

Total time: 2 mins 1.019 secs

I don't use grails but gradle. I copied some things from @rdmueller 's examples.

Here is the part of the DEBUG message I get for every Spec:

11:13:04.602 [DEBUG] [TestEventLogger] SomeSpec > can input search querry and redirecting to results page SKIPPED
11:13:04.602 [DEBUG] [TestEventLogger]
11:13:04.602 [DEBUG] [TestEventLogger] SomeSpec STANDARD_OUT
11:13:04.602 [DEBUG] [TestEventLogger]     entering spec-template
11:13:04.602 [DEBUG] [TestEventLogger]
11:13:04.602 [DEBUG] [TestEventLogger] SomeSpec STANDARD_ERROR
11:13:04.602 [DEBUG] [TestEventLogger]     [Test worker] WARN com.athaydes.spockframework.report.template.TemplateReportCreator - Unexpected error creating report
11:13:04.602 [DEBUG] [TestEventLogger]     java.lang.NullPointerException
11:13:04.603 [DEBUG] [TestEventLogger]          at java.io.Writer.write(Writer.java:157)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.codehaus.groovy.runtime.ResourceGroovyMethods.write(ResourceGroovyMethods.java:741)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.codehaus.groovy.runtime.dgm$1035.invoke(Unknown Source)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
11:13:04.603 [DEBUG] [TestEventLogger]          at com.athaydes.spockframework.report.template.TemplateReportCreator.createReportFor(TemplateReportCreator.groovy:51)
11:13:04.603 [DEBUG] [TestEventLogger]          at com.athaydes.spockframework.report.IReportCreator$createReportFor.call(Unknown Source)
11:13:04.603 [DEBUG] [TestEventLogger]          at com.athaydes.spockframework.report.SpecInfoListener.afterSpec(SpockReportExtension.groovy:149)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.spockframework.runtime.MasterRunListener.afterSpec(MasterRunListener.java:58)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.spockframework.runtime.JUnitSupervisor.afterSpec(JUnitSupervisor.java:192)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.spockframework.runtime.BaseSpecRunner.runSpec(BaseSpecRunner.java:77)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:67)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.spockframework.runtime.Sputnik.run(Sputnik.java:63)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:112)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:56)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
11:13:04.603 [DEBUG] [TestEventLogger]          at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
11:13:04.603 [DEBUG] [TestEventLogger]          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:13:04.603 [DEBUG] [TestEventLogger]          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
11:13:04.603 [DEBUG] [TestEventLogger]          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
11:13:04.604 [DEBUG] [TestEventLogger]          at java.lang.reflect.Method.invoke(Method.java:498)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
11:13:04.604 [DEBUG] [TestEventLogger]          at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
11:13:04.604 [DEBUG] [TestEventLogger]          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:13:04.604 [DEBUG] [TestEventLogger]          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
11:13:04.604 [DEBUG] [TestEventLogger]          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
11:13:04.604 [DEBUG] [TestEventLogger]          at java.lang.reflect.Method.invoke(Method.java:498)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:364)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
11:13:04.604 [DEBUG] [TestEventLogger]          at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
11:13:04.604 [DEBUG] [TestEventLogger]          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
11:13:04.604 [DEBUG] [TestEventLogger]          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
11:13:04.604 [DEBUG] [TestEventLogger]          at java.lang.Thread.run(Thread.java:745)

There is one more thing I found in the DEBUG:

11:13:10.841 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class groovy/lang/Closure from groovy-all-2.4.5.jar
11:13:10.901 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class groovy/lang/GroovyObjectSupport from groovy-all-2.4.5.jar
11:13:10.902 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-scan : failed to scan parent class java/lang/Object, could not find the class file
11:13:10.918 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class geb/Module from geb-core-0.13.1.jar
11:13:10.918 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-scan : failed to scan parent class java/lang/Object, could not find the class file
11:13:10.923 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class geb/spock/GebReportingSpec from geb-spock-0.13.1.jar
11:13:10.928 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class geb/spock/GebSpec from geb-spock-0.13.1.jar
11:13:10.943 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class spock/lang/Specification from spock-core-1.0-groovy-2.4.jar
11:13:10.945 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-scan : failed to scan parent class java/lang/Object, could not find the class file
11:13:10.947 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-scan : failed to scan parent class java/lang/Object, could not find the class file

Are you sure this isn't related to spock-reports?

sorry, it took me a while to notice that I seem to be part of the problem :-)

apply from: "gradle/filmStrip.gradle"

Contains some code which I first used on a grails project. I will now check my own project https://github.com/rdmueller/etka15 and come back to you

@rdmueller you are not part of the problem, but I hope you're part of the solution! I don't know what's going on for @tweinreich!

Nobody is part of the problem. Sorry for whirling up dust, I think I got some answers now and will be back here to report what was going wrong.

Edit: One reason only the summary was created was my incorrect call of the report-method by using report() instead of report 'description' in the specifications.

The other reason it didn't work was a geb.driver.DriverCreationExceptionbecause the chromedriver couldn't be instantiated on mac os x (10.9.5) no matter if the tests were run in a terminal or intellij-IDE. On win10 (with eclipse mars or run in terminal) however it works.

Thank you for your support and the effort you put into this fine project!

hm. @tweinreich so is this now fixed or are there remaining problems?

@rdmueller this one is fixed, thank you for reminding me to close it.