From ff5b16d101b38b1ccb832da912801c127642c16b Mon Sep 17 00:00:00 2001 From: renatoathaydes Date: Mon, 9 Mar 2020 20:32:18 +0100 Subject: [PATCH 1/7] Upgrade Spock to 2.0-M2-groovy-3.0 and Gradle to 6.2.2 --- build.gradle | 27 ++++++++++-------------- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 45112d6e..7c361032 100644 --- a/build.gradle +++ b/build.gradle @@ -8,11 +8,11 @@ plugins { defaultTasks 'clean', 'jar', 'test' group = 'com.athaydes' -version = "1.6.3" +version = "2.0-SNAPSHOT" description = 'This project is a global extension for Spock to create test (or, in Spock terms, Specifications) reports.' -def groovyVersion = '2.0.8' -def spockVersion = '1.1-groovy-2.0' +def groovyVersion = '3.0.1' +def spockVersion = '2.0-M2-groovy-3.0' repositories { mavenLocal() @@ -20,19 +20,14 @@ repositories { } dependencies { - compile "org.codehaus.groovy:groovy:${groovyVersion}" - compile "org.codehaus.groovy:groovy-xml:${groovyVersion}" - compile "org.codehaus.groovy:groovy-json:${groovyVersion}" - compile "org.codehaus.groovy:groovy-templates:${groovyVersion}" - compile "org.spockframework:spock-core:${spockVersion}", { - transitive = false - } - compile 'org.slf4j:slf4j-api:1.7.13' - compile 'junit:junit:4.12' - - testCompile "org.codehaus.groovy:groovy-test:${groovyVersion}" - testCompile "cglib:cglib-nodep:2.2.2" - testCompile "org.slf4j:slf4j-simple:1.7.13" + implementation "org.spockframework:spock-core:${spockVersion}" + implementation 'org.slf4j:slf4j-api:1.7.13' + + testImplementation "org.codehaus.groovy:groovy-test:${groovyVersion}" + testImplementation "cglib:cglib-nodep:2.2.2" + testImplementation "org.slf4j:slf4j-simple:1.7.13" + testImplementation 'org.junit.platform:junit-platform-testkit:1.6.0' + testImplementation 'org.junit.jupiter:junit-jupiter' } test { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 10cb99e6..84a90661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 8d036c83336483baa265ae0826fb79596773f784 Mon Sep 17 00:00:00 2001 From: renatoathaydes Date: Mon, 9 Mar 2020 21:07:04 +0100 Subject: [PATCH 2/7] Fixed most basic problems after Spock 2 upgrade. --- .../report/internal/HtmlReportCreator.groovy | 10 +++--- .../spockframework/report/util/Utils.groovy | 12 ++++--- .../templateReportCreator/spec-template.md | 4 +-- .../report/engine/CanRunSpockSpecs.groovy | 34 +++++++++++++++++++ .../internal/HtmlReportCreatorSpec.groovy | 12 +++---- .../internal/SimulatedReportWriter.groovy | 2 +- .../template/TemplateReportCreatorSpec.groovy | 8 ++--- .../report/internal/VividFakeTestReport.html | 6 ++-- 8 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 src/test/groovy/com/athaydes/spockframework/report/engine/CanRunSpockSpecs.groovy diff --git a/src/main/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreator.groovy b/src/main/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreator.groovy index 42dca63b..4cbfe015 100644 --- a/src/main/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreator.groovy +++ b/src/main/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreator.groovy @@ -14,6 +14,8 @@ import spock.lang.Ignore import spock.lang.PendingFeature import spock.lang.Title +import static com.athaydes.spockframework.report.util.Utils.featureAnnotation + /** * * User: Renato @@ -249,8 +251,8 @@ class HtmlReportCreator extends AbstractHtmlCreator problems.any( Utils.&isFailure ) ? 'failure' : Utils.isSkipped( feature ) ? 'ignored' : '' writeFeatureDescription( builder, name, cssClass, - feature.description.getAnnotation( Ignore ), - feature.description.getAnnotation( PendingFeature ), + featureAnnotation( feature, Ignore ), + featureAnnotation( feature, PendingFeature ), extraInfo, run.feature ) writeFeatureBlocks( builder, feature, problems, iteration ) @@ -271,8 +273,8 @@ class HtmlReportCreator extends AbstractHtmlCreator } : [ ] writeFeatureDescription( builder, feature.name, cssClass, - feature.description.getAnnotation( Ignore ), - feature.description.getAnnotation( PendingFeature ), + featureAnnotation( feature, Ignore ), + featureAnnotation( feature, PendingFeature ), extraInfo, run?.feature ) def problems = run ? run.failuresByIteration.values().collectMany { it } : [ ] diff --git a/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy b/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy index cac5bc52..590fda71 100644 --- a/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy +++ b/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy @@ -90,7 +90,7 @@ class Utils { static boolean isUnrolled( FeatureInfo feature ) { feature.spec?.isAnnotationPresent( Unroll ) || - feature.description?.annotations?.any { Annotation a -> a.annotationType() == Unroll } ?: false + featureAnnotation( feature, Unroll ) != null } static boolean isFailure( SpecProblem problem ) { @@ -103,7 +103,7 @@ class Utils { static boolean isSkipped( FeatureInfo featureInfo ) { // pending features are not marked as skipped but they are always skipped or fail - featureInfo.skipped || featureInfo.description.getAnnotation( PendingFeature ) + featureInfo.skipped || featureAnnotation( featureInfo, PendingFeature ) != null } static int countFeatures( List runs, @@ -141,7 +141,11 @@ class Utils { } static A specAnnotation( SpecData data, Class annotation ) { - data.info.description?.testClass?.getAnnotation( annotation ) + data.info.getAnnotation( annotation ) as A + } + + static A featureAnnotation( FeatureInfo feature, Class annotation ) { + feature.featureMethod.getAnnotation( annotation ) as A } static List nextSpecExtraInfo( SpecData data ) { @@ -192,7 +196,7 @@ class Utils { } static String getSpecClassName( SpecInfo info ) { - info.description?.className ?: specNameFromFileName( info ) + specNameFromFileName( info ) } static List getParentSpecNames( String className ) { diff --git a/src/main/resources/templateReportCreator/spec-template.md b/src/main/resources/templateReportCreator/spec-template.md index 8c7ec72e..63171b70 100644 --- a/src/main/resources/templateReportCreator/spec-template.md +++ b/src/main/resources/templateReportCreator/spec-template.md @@ -64,8 +64,8 @@ features.eachFeature { name, result, blocks, iterations, params -> %> ### $name -<% - writePendingFeature( description.getAnnotation( spock.lang.PendingFeature ) ) +<% + writePendingFeature( featureMethod.getAnnotation( spock.lang.PendingFeature ) ) writeTagOrAttachment( delegate ) if (result != "IGNORED") { if ( utils.isUnrolled( delegate ) ) { diff --git a/src/test/groovy/com/athaydes/spockframework/report/engine/CanRunSpockSpecs.groovy b/src/test/groovy/com/athaydes/spockframework/report/engine/CanRunSpockSpecs.groovy new file mode 100644 index 00000000..cbaf4c71 --- /dev/null +++ b/src/test/groovy/com/athaydes/spockframework/report/engine/CanRunSpockSpecs.groovy @@ -0,0 +1,34 @@ +package com.athaydes.spockframework.report.engine + +import org.junit.platform.engine.DiscoverySelector +import org.junit.platform.testkit.engine.EngineExecutionResults +import org.junit.platform.testkit.engine.EngineTestKit +import org.junit.platform.testkit.engine.EventStatistics +import spock.lang.Specification + +import java.util.function.Consumer + +import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass + +trait CanRunSpockSpecs { + + void runSpec( Class specClass, Consumer assertions = null ) { + if ( assertions ) execute( selectClass( specClass ), assertions ) + else execute( selectClass( specClass ) ) + } + + private static void execute( DiscoverySelector selector, Consumer statisticsConsumer ) { + execute( selector ) + .testEvents() + .debug() + .assertStatistics( statisticsConsumer ) + } + + private static EngineExecutionResults execute( DiscoverySelector selector ) { + return EngineTestKit + .engine( "spock" ) + .selectors( selector ) + .execute() + } + +} diff --git a/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreatorSpec.groovy b/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreatorSpec.groovy index ae7546fc..cba3a5a9 100644 --- a/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreatorSpec.groovy +++ b/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportCreatorSpec.groovy @@ -7,10 +7,9 @@ import com.athaydes.spockframework.report.SpecInfoListener import com.athaydes.spockframework.report.SpockReportExtension import com.athaydes.spockframework.report.UnrolledSpec import com.athaydes.spockframework.report.VividFakeTest +import com.athaydes.spockframework.report.engine.CanRunSpockSpecs import groovy.xml.MarkupBuilder import org.junit.runner.Description -import org.junit.runner.notification.RunNotifier -import org.spockframework.runtime.Sputnik import org.spockframework.runtime.model.SpecInfo import spock.lang.Unroll @@ -24,7 +23,8 @@ import static com.athaydes.spockframework.report.internal.TestHelper.minify * User: Renato */ @Unroll -class HtmlReportCreatorSpec extends ReportSpec { +class HtmlReportCreatorSpec extends ReportSpec +implements CanRunSpockSpecs { static final String UNKNOWN = 'Unknown' static final char DS = StringFormatHelper.ds @@ -84,7 +84,7 @@ class HtmlReportCreatorSpec extends ReportSpec { PredictableStringHashCode.code = 0 use( configShowCodeBlocks, ConfigOutputDir, PredictableTimeResponse, FakeKnowsWhenAndWhoRanTest, NoTocGenerated, PredictableStringHashCode ) { - new Sputnik( specification ).run( new RunNotifier() ) + runSpec( specification ) } then: @@ -210,7 +210,7 @@ class HtmlReportCreatorSpec extends ReportSpec { use( ConfigOutputDir, PredictableTimeResponse, FakeKnowsWhenAndWhoRanTest, NoTocGenerated, PredictableStringHashCode, ShowCodeBlocksDisabled ) { - new Sputnik( UnrolledSpec ).run( new RunNotifier() ) + runSpec( UnrolledSpec ) } then: @@ -283,7 +283,7 @@ class HtmlReportCreatorSpec extends ReportSpec { "A Specification containing different types of features is run by Spock" PredictableStringHashCode.code = 0 use( ConfigOutputDir, PredictableTimeResponse, FakeKnowsWhenAndWhoRanTest, NoTocGenerated, PredictableStringHashCode ) { - new Sputnik( specification ).run( new RunNotifier() ) + runSpec( specification ) } then: diff --git a/src/test/groovy/com/athaydes/spockframework/report/internal/SimulatedReportWriter.groovy b/src/test/groovy/com/athaydes/spockframework/report/internal/SimulatedReportWriter.groovy index 3baa7bf6..ca2f032d 100644 --- a/src/test/groovy/com/athaydes/spockframework/report/internal/SimulatedReportWriter.groovy +++ b/src/test/groovy/com/athaydes/spockframework/report/internal/SimulatedReportWriter.groovy @@ -15,7 +15,7 @@ class SimulatedReportWriter { assert write( file, threadCount ).await( 10, TimeUnit.SECONDS ), "Did not finish writing within timeout" } - static write( File file, int threadCount ) { + static CountDownLatch write( File file, int threadCount ) { final counter = new CountDownLatch( threadCount ) ( 1..threadCount ).each { n -> diff --git a/src/test/groovy/com/athaydes/spockframework/report/template/TemplateReportCreatorSpec.groovy b/src/test/groovy/com/athaydes/spockframework/report/template/TemplateReportCreatorSpec.groovy index 9fc860ae..c08652d3 100644 --- a/src/test/groovy/com/athaydes/spockframework/report/template/TemplateReportCreatorSpec.groovy +++ b/src/test/groovy/com/athaydes/spockframework/report/template/TemplateReportCreatorSpec.groovy @@ -4,17 +4,17 @@ import com.athaydes.spockframework.report.FakeTest import com.athaydes.spockframework.report.SpecInfoListener import com.athaydes.spockframework.report.SpockReportExtension import com.athaydes.spockframework.report.VividFakeTest +import com.athaydes.spockframework.report.engine.CanRunSpockSpecs import com.athaydes.spockframework.report.internal.HtmlReportCreatorSpec import com.athaydes.spockframework.report.internal.StringFormatHelper -import org.junit.runner.notification.RunNotifier -import org.spockframework.runtime.Sputnik import spock.lang.Specification import spock.lang.Unroll import java.nio.file.Paths @Unroll -class TemplateReportCreatorSpec extends Specification { +class TemplateReportCreatorSpec extends Specification + implements CanRunSpockSpecs { def "A correct Template report is generated for a #specName including different types of features"() { given: @@ -24,7 +24,7 @@ class TemplateReportCreatorSpec extends Specification { when: "A Specification containing different types of features is run by Spock" use( reportCreator, HtmlReportCreatorSpec.PredictableTimeResponse ) { - new Sputnik( specification ).run( new RunNotifier() ) + runSpec( specification ) } then: diff --git a/src/test/resources/com/athaydes/spockframework/report/internal/VividFakeTestReport.html b/src/test/resources/com/athaydes/spockframework/report/internal/VividFakeTestReport.html index 01188878..83f6226b 100644 --- a/src/test/resources/com/athaydes/spockframework/report/internal/VividFakeTestReport.html +++ b/src/test/resources/com/athaydes/spockframework/report/internal/VividFakeTestReport.html @@ -80,9 +80,9 @@

Features:

Then:
-
verifyAll { // line 25
-
    x == y
-    y == x
+		
verifyAll {
+
    x == y // line 26
+
    y == x
 }
From 3869936be23d63ed91b76db56005545c4b081f28 Mon Sep 17 00:00:00 2001 From: renatoathaydes Date: Tue, 10 Mar 2020 19:37:31 +0100 Subject: [PATCH 3/7] Include Junit Jupiter version. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7c361032..030df67c 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ dependencies { testImplementation "cglib:cglib-nodep:2.2.2" testImplementation "org.slf4j:slf4j-simple:1.7.13" testImplementation 'org.junit.platform:junit-platform-testkit:1.6.0' - testImplementation 'org.junit.jupiter:junit-jupiter' + testImplementation 'org.junit.jupiter:junit-jupiter:5.6.0' } test { From a020778c293c3c9ceb81fab673c6a789c01aae84 Mon Sep 17 00:00:00 2001 From: renatoathaydes Date: Tue, 10 Mar 2020 19:38:17 +0100 Subject: [PATCH 4/7] Version set to 2.0-RC1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 030df67c..78e514ca 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { defaultTasks 'clean', 'jar', 'test' group = 'com.athaydes' -version = "2.0-SNAPSHOT" +version = "2.0-RC1" description = 'This project is a global extension for Spock to create test (or, in Spock terms, Specifications) reports.' def groovyVersion = '3.0.1' From 86cf8d4a8731f64df80a9f3a1edd507d14a70fb0 Mon Sep 17 00:00:00 2001 From: renatoathaydes Date: Fri, 15 May 2020 18:54:30 +0200 Subject: [PATCH 5/7] Fixing more tests after Spock 2.0 upgrade. --- build.gradle | 2 ++ .../report/SpockReportExtension.groovy | 18 ++++++++---- .../spockframework/report/util/Utils.groovy | 10 +++++-- .../internal/HtmlReportAggregatorSpec.groovy | 29 ++++++++++--------- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/build.gradle b/build.gradle index 78e514ca..3dcc7d4e 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,8 @@ dependencies { } test { + useJUnitPlatform() + maxParallelForks = 4 exclude '**/*FakeTest.class', '**/UnrolledSpec.class', '**/SpecIncludingExtraInfo.class' systemProperty 'project.buildDir', project.buildDir diff --git a/src/main/groovy/com/athaydes/spockframework/report/SpockReportExtension.groovy b/src/main/groovy/com/athaydes/spockframework/report/SpockReportExtension.groovy index 142ca0a6..0f727503 100644 --- a/src/main/groovy/com/athaydes/spockframework/report/SpockReportExtension.groovy +++ b/src/main/groovy/com/athaydes/spockframework/report/SpockReportExtension.groovy @@ -43,13 +43,13 @@ class SpockReportExtension implements IGlobalExtension { void start() { if ( !initialized.getAndSet( true ) ) { log.info( "Got configuration from Spock: {}", configuration ) - log.debug "Configuring ${this.class.name}" + log.debug "Configuring ${ this.class.name }" def config = configLoader.loadConfig( configuration ) // Read the class report property and exit if its not set String commaListOfReportClasses = config.remove( IReportCreator.name ) if ( !commaListOfReportClasses ) { - log.warn( "Missing property: ${IReportCreator.name} - no report classes defined" ) + log.warn( "Missing property: ${ IReportCreator.name } - no report classes defined" ) return } @@ -77,7 +77,7 @@ class SpockReportExtension implements IGlobalExtension { if ( reportCreator != null ) { specInfo.addListener createListener() } else { - log.warn "Not creating report for ${specInfo.name} as reportCreator is null" + log.warn "Not creating report for ${ specInfo.name } as reportCreator is null" } } @@ -123,6 +123,10 @@ class SpecInfoListener implements IRunListener { @Override synchronized void beforeSpec( SpecInfo spec ) { + if ( specData != null ) { + log.debug( 'Unexpected state: Current specData is {}, not done yet and already started with {}', + specData?.info?.name, spec.name ) + } specData = new SpecData( info: spec ) log.debug( "Before spec: {}", Utils.getSpecClassName( specData ) ) startT = System.currentTimeMillis() @@ -167,6 +171,10 @@ class SpecInfoListener implements IRunListener { @Override void afterSpec( SpecInfo spec ) { + if ( specData == null ) { + log.debug( 'Unexpected state: running afterSpec without having a specData' ) + return + } assert specData.info == spec log.debug( "After spec: {}", Utils.getSpecClassName( specData ) ) specData.totalTime = System.currentTimeMillis() - startT @@ -179,7 +187,7 @@ class SpecInfoListener implements IRunListener { try { def errorInInitialization = ( specData == null ) log.debug( "Error on spec: {}", errorInInitialization ? - "<${EmptyInitializationException.INIT_ERROR}>" : + "<${ EmptyInitializationException.INIT_ERROR }>" : Utils.getSpecClassName( specData ) ) if ( errorInInitialization ) { @@ -249,7 +257,7 @@ class SpecInfoListener implements IRunListener { private void markWithInitializationError( FeatureInfo featureInfo ) { def originalGetName = featureInfo.&getName - featureInfo.metaClass.getName = { "[${EmptyInitializationException.INIT_ERROR}] ${originalGetName()}" } + featureInfo.metaClass.getName = { "[${ EmptyInitializationException.INIT_ERROR }] ${ originalGetName() }" } } private IterationInfo dummySpecIteration() { diff --git a/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy b/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy index 590fda71..b17a76c9 100644 --- a/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy +++ b/src/main/groovy/com/athaydes/spockframework/report/util/Utils.groovy @@ -141,11 +141,15 @@ class Utils { } static
A specAnnotation( SpecData data, Class annotation ) { - data.info.getAnnotation( annotation ) as A + data.info.isAnnotationPresent( annotation ) + ? data.info.getAnnotation( annotation ) as A + : null } static A featureAnnotation( FeatureInfo feature, Class annotation ) { - feature.featureMethod.getAnnotation( annotation ) as A + feature.featureMethod.isAnnotationPresent( annotation ) + ? feature.featureMethod.getAnnotation( annotation ) as A + : null } static List nextSpecExtraInfo( SpecData data ) { @@ -227,7 +231,7 @@ class Utils { def lastDotInFileName = fileName.lastIndexOf( '.' ) def name = lastDotInFileName > 0 ? fileName.substring( 0, lastDotInFileName ) : fileName - return specInfo.package + '.' + name + return (specInfo.package ? specInfo.package + '.' : '') + name } @Nullable diff --git a/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportAggregatorSpec.groovy b/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportAggregatorSpec.groovy index c41adc4a..73b8c455 100644 --- a/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportAggregatorSpec.groovy +++ b/src/test/groovy/com/athaydes/spockframework/report/internal/HtmlReportAggregatorSpec.groovy @@ -3,8 +3,8 @@ package com.athaydes.spockframework.report.internal import com.athaydes.spockframework.report.ReportSpec import com.athaydes.spockframework.report.SpockReportExtension import groovy.xml.MarkupBuilder -import org.junit.runner.Description import org.spockframework.runtime.model.FeatureInfo +import org.spockframework.runtime.model.MethodInfo import org.spockframework.runtime.model.SpecInfo import java.util.concurrent.TimeUnit @@ -26,7 +26,7 @@ class HtmlReportAggregatorSpec extends ReportSpec { and: "A clean output directory" - def outputDir = "build/${this.class.simpleName}" + def outputDir = "build/${ this.class.simpleName }" def outputDirFile = new File( outputDir ) if ( outputDirFile.directory ) { assert outputDirFile.deleteDir() @@ -51,7 +51,7 @@ class HtmlReportAggregatorSpec extends ReportSpec { "The spec data is provided to the HtmlReportAggregator" def specDataStub = Stub( SpecData ) { getInfo() >> Stub( SpecInfo ) { - getDescription() >> Description.createTestDescription( 'Spec1', 'Spec1' ) + getFilename() >> 'Spec1' } } aggregator.aggregateReport( specDataStub, stats ) @@ -77,7 +77,7 @@ class HtmlReportAggregatorSpec extends ReportSpec { and: "A clean output directory" - def outputDir = "build/${this.class.simpleName}" + def outputDir = "build/${ this.class.simpleName }" def outputDirFile = new File( outputDir ) if ( outputDirFile.directory ) { assert outputDirFile.deleteDir() @@ -107,7 +107,7 @@ class HtmlReportAggregatorSpec extends ReportSpec { "The spec data is provided to the HtmlReportAggregator" def specDataStub = Stub( SpecData ) { getInfo() >> Stub( SpecInfo ) { - getDescription() >> Description.createTestDescription( 'Spec1', 'Spec1' ) + getFilename() >> 'Spec1' } } aggregator.aggregateReport( specDataStub, stats ) @@ -122,8 +122,8 @@ class HtmlReportAggregatorSpec extends ReportSpec { "The contents are functionally the same as expected" def expectedProjectHeader = """
- Project: ${aggregator.projectName} - Version: ${aggregator.projectVersion} + Project: ${ aggregator.projectName } + Version: ${ aggregator.projectVersion }
""" @@ -148,7 +148,7 @@ class HtmlReportAggregatorSpec extends ReportSpec { and: "An output directory" - def outputDir = "build/${this.class.simpleName}" + def outputDir = "build/${ this.class.simpleName }" and: "A HtmlReportAggregator with mocked dependencies and the test css style" @@ -158,9 +158,12 @@ class HtmlReportAggregatorSpec extends ReportSpec { when: "The specs data is provided to the HtmlReportAggregator" allSpecs.each { String name, Map stats -> + def pkg = name.contains( '.' ) ? name.substring( 0, name.lastIndexOf( '.' ) ) : '' + def filename = name.contains( '.' ) ? name.substring( name.lastIndexOf( '.' ) + 1 ) : name def specDataStub = Stub( SpecData ) { getInfo() >> Stub( SpecInfo ) { - getDescription() >> Description.createTestDescription( name, name ) + getFilename() >> filename + getPackage() >> pkg } } aggregator.aggregateReport( specDataStub, stats ) @@ -186,22 +189,22 @@ class HtmlReportAggregatorSpec extends ReportSpec { and: 'Some realistic, mocked out specData' def data = Stub( SpecData ) { getInfo() >> Stub( SpecInfo ) { - getDescription() >> Description.createTestDescription( 'myClass', 'myClass' ) + getFilename() >> 'myClass' getAllFeaturesInExecutionOrder() >> [ Stub( FeatureInfo ) { isSkipped() >> false - getDescription() >> Description.createTestDescription( 'myClass', 'myClass' ) getName() >> 'cFeature' + getFeatureMethod() >> Mock( MethodInfo ) }, Stub( FeatureInfo ) { isSkipped() >> true - getDescription() >> Description.createTestDescription( 'myClass', 'myClass' ) getName() >> 'aFeature' + getFeatureMethod() >> Mock( MethodInfo ) }, Stub( FeatureInfo ) { isSkipped() >> false - getDescription() >> Description.createTestDescription( 'myClass', 'myClass' ) getName() >> 'bFeature' + getFeatureMethod() >> Mock( MethodInfo ) } ] } From 814b5e0b85c4b6e9c099052b7928b93c0bca9a3e Mon Sep 17 00:00:00 2001 From: renatoathaydes Date: Fri, 15 May 2020 19:22:23 +0200 Subject: [PATCH 6/7] Preparing 2.0-RC2 release. --- README.md | 29 +++++++++++++++++++---------- news.md | 8 ++++++++ releases/Release_Notes.txt | 4 ++++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 16d181fb..86f662c9 100644 --- a/README.md +++ b/README.md @@ -58,13 +58,17 @@ def "My feature"() { ### If you are using Maven +> NOTE about Spock/Groovy versions: +> The versions below work with the new Spock 2 / Groovy 3 versions. +> If you want to stay with Spock 1 and Groovy 2.5.x, use spock-reports version 1.7.1. + Add ``spock-reports`` to your ````: ```xml com.athaydes spock-reports - 1.6.3 + 2.0-RC2 test @@ -79,13 +83,13 @@ Add ``spock-reports`` to your ````: org.slf4j slf4j-api - 1.7.13 + 1.7.30 test org.slf4j slf4j-simple - 1.7.13 + 1.7.30 test ``` @@ -98,21 +102,26 @@ repositories { jcenter() } +test { + useJUnitPlatform() +} + dependencies { - testCompile( 'com.athaydes:spock-reports:1.6.3' ) { + // you can use testRuntimeClasspath if you don't want to use spock-report-specific features in your Specs + testImplementation( 'com.athaydes:spock-reports:2.0-RC2' ) { transitive = false // this avoids affecting your version of Groovy/Spock } // if you don't already have slf4j-api and an implementation of it in the classpath, add this! - testCompile 'org.slf4j:slf4j-api:1.7.13' - testCompile 'org.slf4j:slf4j-simple:1.7.13' + testImplementation 'org.slf4j:slf4j-api:1.7.30' + testRuntimeClasspath 'org.slf4j:slf4j-simple:1.7.30' } ``` If you prefer, you can just download the jar directly from [JCenter](http://jcenter.bintray.com/com/athaydes/spock-reports/). -The only dependencies this project has are Groovy version 2.0+ (only the -`groovy`, `groovy-templates`, `groovy-xml` and `groovy-json` -modules are required) and `Spock`, but if you're using Spock (version 0.7-groovy-2.0+) then you already have them all! +The only dependencies this project has are Groovy (only the +`groovy`, `groovy-templates`, `groovy-xml` and `groovy-json` modules are required) +and `Spock`, of course. ## Customizing spock-reports logging @@ -133,7 +142,7 @@ To get rid of the warning, add a dependency on a logging framework that implemen For example, to use `slf4j-simple`, add this line to your Gradle dependencies (or the equivalent XML in your Maven pom): ```groovy -testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.13' +testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30' ``` To configure the logging framework itself, please check the documentation of the framework you decide to use. diff --git a/news.md b/news.md index 3c5743aa..6a224ed1 100644 --- a/news.md +++ b/news.md @@ -2,6 +2,14 @@ > Most recent first +* `15th of May 2020` + +spock-reports has caught up with the new Groovy and Spock releases! +The new version, 2.0-RC2, works with Groovy 3 and Spock 2. + +This is only a release-candidate (hence RC in the version), so please give it a go and as soon as Spock 2 is stabilized, +hopefully spock-reports 2 will also have been well tested enough to update version to 2.0 itself. + * `04th of January 2020` spock-reports version 1.6.3 released with several bug fixes, including some important changes on how feature counts diff --git a/releases/Release_Notes.txt b/releases/Release_Notes.txt index 9679da81..4288a140 100644 --- a/releases/Release_Notes.txt +++ b/releases/Release_Notes.txt @@ -1,3 +1,7 @@ +2.0-RC2 - 2020 May 15 + +* Upgrade to Spock 2 and Groovy 3. + 1.6.3 - 2020 January 04 * #144 include tests originating from a jar rather than the project's source code into the reports. From 80c60daee3f47aa2bac7b6d5fdad0460efab1680 Mon Sep 17 00:00:00 2001 From: renatoathaydes Date: Fri, 15 May 2020 19:46:52 +0200 Subject: [PATCH 7/7] Fixed mess up in dependencies. --- build.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index cf443671..a39fa965 100644 --- a/build.gradle +++ b/build.gradle @@ -25,9 +25,11 @@ dependencies { implementation "org.codehaus.groovy:groovy-json:${groovyVersion}" implementation "org.codehaus.groovy:groovy-templates:${groovyVersion}" implementation "org.spockframework:spock-core:${spockVersion}", { - transitive = false + exclude group: 'org.codehaus.groovy' } - implementation 'org.slf4j:slf4j-api:1.7.13' + implementation 'org.slf4j:slf4j-api:1.7.30' + testImplementation 'org.junit.platform:junit-platform-testkit:1.6.0' + testImplementation 'org.junit.jupiter:junit-jupiter:5.6.0' testImplementation "org.codehaus.groovy:groovy-test:${groovyVersion}" testImplementation "cglib:cglib-nodep:3.2.10" testImplementation "org.slf4j:slf4j-simple:1.7.30"