Test.single does not work when using an init-script


(merejy) #1

I’m using the java plugin and I’d like to run only a single junit test.

There’s a init-script in the init.d folder and when executing “gradle -Dsingle.test=blabla test”, it runs all the tests. I experience the same behavior when using --init-script instead. If I move everything from the init-script to the build.gradle, then single.test works properly.

Sadly, the workaround suggested here GRADLE-1553 does not work for me.


(Luke Daley) #2

I’ve raised GRADLE-2348 for this.


(René Groeschke) #3

just to be sure, in your post you mentioned the console command “gradle -Dsingle.test=blabla…”. But the correct syntax is “gradle -Dtest.single=blablabla…” just a typo?

cheers, René


(merejy) #4

Ooops yes you’re right, it’s a typo. I’m executing the console commande “-Dtest.single”

Can I somehow edit my initial post?


(Luke Daley) #5

unfortunately not. We’ve got a long standing issue with the company behind this forum software to get this fixed.


(Adam Murdoch) #6

If I move everything from the init-script to the build.gradle, then single.test works properly.

What do you mean by ‘everything’ here? What are you trying to do in the init script?


(merejy) #7

My goal is not to have a build.gradle in the project folder, and use only init-scripts. However just to be sure, I tested with an empty build.gradle, and test.single still fails.

In the init-script, only dependency, groupId etc… are set, no tasks are defined. Here its content (without irrelevant stuff): import groovy.json.JsonSlurper

addListener(new ApplyPluginListener())

class ApplyPluginListener extends BuildAdapter {

def devRepository = “http://artifacts/content/groups/public/

public void projectsEvaluated(Gradle gradle) {

gradle.rootProject { apply plugin: ‘java’ }

gradle.rootProject { apply plugin: ‘eclipse’ }

// Computing groupId, version, dependencies, etc…

gradle.rootProject.group = groupId

gradle.rootProject.version = version

for (String dep : depArr){

gradle.rootProject.dependencies.add(“compile”, dep)

}

gradle.rootProject.dependencies.add(“testCompile”, “junit:junit:4.+”)

gradle.rootProject.repositories {

maven { url devRepository }

}

gradle.rootProject.sourceSets {

main {

java { srcDir ‘src/java’ }

resources { srcDir ‘src/java’ }

}

test {

java { srcDir ‘src/test’ }

resources { srcDir ‘src/test’ }

}

}

}


(Luke Daley) #8

My goal is not to have a build.gradle in the project folder, and use only init-scripts.

why?


(merejy) #9

Right now we’re using an in-house build tool. Each project has a maven-like XML file descriptor. The goal is to have the init-script to parse this XML file and feed the information to Gradle. This way the migration will be smoother for the developers, who will stick with this XML file.