I'm trying to update my test project from Spock 1.3 to 2.0:
testImplementation group: 'org.spockframework', name: 'spock-core', version: '2.0-groovy-2.5'
But getting the following error at the test start:
':compileTestGroovy'. Caused by: java.lang.NoClassDefFoundError: org.junit.rules.TestName
As I understand, Spock 2.0 does not contain required internal dependency with this class anymore. I added the junit-4 dependency explicitly as it is in the Sample project:
testImplementation group: 'org.spockframework', name: 'spock-junit4', version: '2.0-groovy-2.5'
And this solved the above issue. But Now I'm getting "test events were not received" error.
Could anyone explain please what else should be changed in order to make new Spock launch the tests?
UPDATE Adding the build.gradle. Tests have started with the below configuration:
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath "io.qameta.allure:allure-gradle:2.8.1"
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.24.5'
classpath "io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE"
}
}
plugins {
id "idea"
id "groovy"
id "io.qameta.allure" version "2.5"
}
apply plugin: "application"
apply plugin: "groovy"
apply plugin: 'maven-publish'
apply plugin: 'io.qameta.allure'
sourceCompatibility = 1.8
dependencies {
compile 'org.codehaus.groovy:groovy:2.5.2'
implementation group: 'org.codehaus.groovy', name: 'groovy-dateutil', version: '2.5.2'
implementation group: 'org.codehaus.groovy', name: 'groovy-json', version: '2.5.2'
compile "org.testng:testng:6.9.8"
compileOnly "io.micronaut:micronaut-bom:$micronautVersion"
implementation "io.micronaut:micronaut-security-jwt"
implementation "io.micronaut:micronaut-inject-groovy"
implementation "io.micronaut:micronaut-validation"
implementation "io.micronaut:micronaut-http-server-netty"
implementation "io.micronaut:micronaut-http-client"
compile "io.micronaut:micronaut-aop"
implementation "io.micronaut:micronaut-runtime"
compile 'ch.qos.logback:logback-classic:1.1.7'
compile "org.aspectj:aspectjweaver:1.9.2"
testImplementation "io.micronaut.test:micronaut-test-spock"
testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
testCompile group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '3.0.0'
testImplementation group: 'org.spockframework', name: 'spock-core', version: '2.0-groovy-2.5'
testImplementation group: 'org.spockframework', name: 'spock-junit4', version: '2.0-groovy-2.5'
testCompile("org.gebish:geb-spock:3.4") {
/* https://github.com/micronaut-projects/micronaut-test/issues/100 */
exclude group: "org.codehaus.groovy", module: "groovy-all"
}
testCompile "org.seleniumhq.selenium:selenium-java:3.141.59"
compile "com.codeborne:selenide:4.12.0"
testCompile 'org.slf4j:slf4j-jdk14:1.7.25'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
implementation group: 'io.qameta.allure', name: 'allure-spock', version: '2.15.0'
testCompile group: 'org.monte', name: 'screen-recorder', version: '0.7.7'
compile group: 'org.springframework', name: 'spring-messaging', version: '4.3.27.RELEASE'
compile group: 'org.springframework', name: 'spring-websocket', version: '4.3.27.RELEASE'
compile group: 'javax.websocket', name: 'javax.websocket-api', version: '1.1'
compile group: 'org.apache.tomcat', name: 'tomcat-websocket', version: '8.0.20'
compile group: 'io.github.http-builder-ng', name: 'http-builder-ng-core', version: '1.0.4'
driver group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'
}
test {
exclude '**/*/**'
}
allure {
version = '2.15.0'
aspectjweaver = true
autoconfigure = false
resultsDir = file("$buildDir/allure-results")
reportDir = file("$buildDir/allure-report")
useSpock {
version = '2.15.0'
}
useTestNG {
version = '2.15.0'
}
}
task apiTest(type: Test, group: 'verification', dependsOn: ['fetchTestFiles']) {
outputs.upToDateWhen { false }
include '**/api/**'
getFilter().setFailOnNoMatchingTests(false)
useJUnitPlatform()
List<String> testNamePatterns = System.getProperty('API_TEST_NAME_PATTERNS')?.split(' ')?.findAll { it }
if (testNamePatterns) {
println("GOT API_TEST_FILTER PROPAGATED $testNamePatterns")
filter {
testNamePatterns.each {
includeTestsMatching(it)
}
}
}
doFirst {
def weaver = configurations.compile.find { it.name.contains("aspectjweaver") }
jvmArgs = jvmArgs << "-javaagent:$weaver"
project.gradle.startParameter.systemPropertiesArgs.entrySet().collect() {
systemProperty it.key, it.value
}
}
}
For now, I'm getting reporting error, which is not related to the initial question. Am I righ assuming that current Allure-Spock implementation does not support spock 2.0? :
org.spockframework.runtime.model.FeatureInfo.getDescription()Lorg/junit/runner/Description;
java.lang.NoSuchMethodError: org.spockframework.runtime.model.FeatureInfo.getDescription()Lorg/junit/runner/Description;