1
votes

since a few days tests in Jenkins are being canceled. The error I got in there is:

A problem occurred configuring root project 'MyAutomationTests'.

Configuration with name 'testCompile' not found.

This is my build.gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.qameta.allure:allure-gradle:2.3"

    }
}

group 'xyz'
version '1.0-SNAPSHOT'

apply plugin: 'io.qameta.allure'

repositories {
    mavenCentral()
}


def props = new Properties()
file("testsConfig.properties").withInputStream { props.load(it) }

allure {
    version = '2.4.1'
    aspectjweaver = true
    autoconfigure = true
    resultsDir = file(props.getProperty("projectPath")+'/allure-results')
    reportDir = file('raport/allure-results')
    clean
}

apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8

subprojects {
    dependencies {
        testCompile 'junit:junit:4.12'
        testCompile 'io.appium:java-client:7.0.0'
        testCompile 'org.assertj:asertj-core:3.12.2'
        testCompile 'org.testng:testng:6.14.3'
        testCompile 'io.qameta.allure:allure-testng:2.13.1'
        testCompile 'log4j:log4j:1.2.17'
        testCompile 'com.jcabi:jcabi-log:0.17.2'
        testCompile 'org.slf4j:slf4j-log4j12:1.7.30'
        testCompile 'org.testobject:testobject-appium-java-api:0.1.14'
        testCompile 'io.rest-assured:rest-assured:4.3.2'
    }

}

test {
    System.setProperty("log4j.defaultInitOverride", "false")
    dependsOn cleanTest
    test.testLogging.showStandardStreams = false
    useTestNG() {
        systemProperties(props)
        systemProperties = System.getProperties()
        options.suites("src/test/resources/testng.xml")
    }
}

Our automatic tests in Jenkins were working fine until a few days ago. Since then they do not compile with error given on the very beginning of this issue. There was 'implementation group' in the dependencies block of code but I recently changed it to testCompile. 'implementation group' was working just fine but it started to pop out error with the testCompile. In my understanding after I apply java plugin to the dependencies the configuration should be there but somehow it does not work.

What I tried:

  1. Tried to manuver with testCompile() or testImplementation, testImplementation group etc, also changed name convention from 'junit', name: 'junit', version: '4.12' to the version that it is there right now.
  2. Applied idea plugin
  3. Applied java plugin in the very top of the gradle build
  4. Changed testCompile to testImplementation
  5. Applied java plugin in every block of code (primitive but I ran out of ideas)
  6. Updated dependencies in our project

I can see it uses /path/to/.gradle/daemon/7.0 but receive information on the end: Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0 however I do not suppose the Gradle itself is a problem. Before we had an gradle 7.0 and it was working perfectly fine with the given confioguration and it was always popping the same error.

Please help if it is possible.

Regards

2
I assume you upgraded to Gradle 7.0? docs.gradle.org/current/userguide/…tim_yates
Do you have a reproducer? testImplementation should do the trick.thokuest
I have gradle 7.0 version. I also used testImplementation instead of testCompile- when I used testImplementation I got the same error: Configuration with name 'testCompile' not found.Toms
I found this issue when debugging: [org.codehaus.groovy.vmplugin.VMPluginFactory] Trying to create VM plugin org.codehaus.groovy.vmplugin.v9.Java9 by checking java.lang.Module, but failed: java.lang.ClassNotFoundException: java.lang.Module. Might it be related to gradle?Toms

2 Answers

2
votes

The workaround mentioned in this link works fine with me

All you need to do is to add the following block of code to build.gradle file:

configurations {
   testCompile
}
0
votes

For people who will face same problem as me:

I triggered gradle via "./gradle" command. I changed it to "./gradlew" and it worked like a charm.