From 5e19b54769a84b1fa20ff9a4492a55fa72de928a Mon Sep 17 00:00:00 2001 From: Gleethos Date: Sun, 2 Apr 2023 16:42:40 +0200 Subject: [PATCH 1/2] add some more important information to readme which is needed to getting the project up and running --- README.md | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5e49578..0d7053c 100644 --- a/README.md +++ b/README.md @@ -24,20 +24,34 @@ served dynamically. ## Getting Started To create living react documentation from your Spock test suite, -you need 2 simple dependencies: +you need a few simple dependencies: -The [Spock test framework](https://github.com/spockframework/spock): +First and foremost, the [Spock test framework](https://github.com/spockframework/spock): ```groovy - testImplementation platform("org.spockframework:spock-bom:$spockVersion") - testImplementation "org.spockframework:spock-core" +testImplementation platform("org.spockframework:spock-bom:$spockVersion") +testImplementation "org.spockframework:spock-core" ``` -The [Spock reports plugin](https://github.com/renatoathaydes/spock-reports): +Keep in mind that Spock is based on Groovy, so make sure you have +the Groovy plugin for Gradle, otherwise Gradle will not be able +to find (and execute) your Spock tests: ```groovy - // you can use testRuntimeClasspath if you don't want to use spock-report-specific features in your Specs - testImplementation( "com.athaydes:spock-reports:$spockReportsVersion" ) { - transitive = false // this avoids affecting your version of Groovy/Spock - } +plugins { + id 'groovy' + // ... some other plugins ... +} ``` +And finally you need the [Spock reports plugin](https://github.com/renatoathaydes/spock-reports) +which is used to generate the raw json files from your Spock tests: +```groovy +// you can use testRuntimeClasspath if you don't want to use spock-report-specific features in your Specs +testImplementation( "com.athaydes:spock-reports:$spockReportsVersion" ) { + 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! (needed for reports) +testImplementation 'org.slf4j:slf4j-api:1.7.30' +testImplementation 'org.slf4j:slf4j-simple:1.7.30' // You might need to adjust the version for spock-reports... +``` + After you have added the dependencies to your project, you need to give the report plugin some configuration and templates to work with. From 3449c974a7adb1127fc482b884046137ee9da7c2 Mon Sep 17 00:00:00 2001 From: Gleethos Date: Sun, 2 Apr 2023 16:45:49 +0200 Subject: [PATCH 2/2] fix exception in template file and add try catch for logging future problems! --- spock-conf/templates/spec-template.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spock-conf/templates/spec-template.json b/spock-conf/templates/spec-template.json index 6c96c93..e163bb7 100644 --- a/spock-conf/templates/spec-template.json +++ b/spock-conf/templates/spec-template.json @@ -137,7 +137,7 @@ def strCode = { it == null || it.isEmpty() ? "" : (it.size() == 1 ? ('"'+simpleE println("Generating json for '"+utils.getSpecClassName( data )+"' now!") - +try { def stats = utils.stats( data ) def subjects = utils.specAnnotation( data, spock.lang.Subject )?.value() if ( subjects == null ) subjects = [] @@ -166,7 +166,7 @@ def specTitle = utils.specAnnotation( data, spock.lang.Title )?.value() } out << '},' out << '"see":[' - if ( feature.attachments.size > 0 ) out << feature.attachments.collect({v->esc(v.url)}).collect({'"'+it+'"'}).join(",") + if ( feature.attachments.size() > 0 ) out << feature.attachments.collect({v->esc(v.url)}).collect({'"'+it+'"'}).join(",") out << '],' } def writeHeaders = { headers -> @@ -256,4 +256,10 @@ def specTitle = utils.specAnnotation( data, spock.lang.Title )?.value() %> ], "generator":"<%out << com.athaydes.spockframework.report.SpockReportExtension.PROJECT_URL%>" -} \ No newline at end of file +} +<% +} catch (Exception e) { + e.printStackTrace() + println("ERROR: Failed to generate json for '"+utils.getSpecClassName( data )+"'! Exception: "+e) +} +%> \ No newline at end of file