Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run single integration test with gradle

Tags:

I'm trying to run a single integration tests using gradle's -Dtest.single flag. I have added another source set, src/integrationTest and put the tests in there. I have an integration test task

task integrationTests(type: Test) {
    dependsOn 'assemble', 'integrationTestClasses'    
    testClassesDir = sourceSets.integrationTest.output.classesDir
    classpath = sourceSets.integrationTest.runtimeClasspath
}

This runs fine, but if I try to run a single test it tells me it cannot find a matching test. I don't want to have to run every integration test each time I am writing a new one. Is there a way to do this?

like image 673
Jeff Storey Avatar asked Aug 05 '13 15:08

Jeff Storey


People also ask

Does Gradle run tests in parallel?

One of the best features in Gradle for JVM-related projects is its ability to run tests in parallel. As discussed in the Gradle documentation, this implemented by setting the maxParallelForks property inside a test block in the build.


2 Answers

Since Gradle 1.10 you can write:

 //select specific test method
gradle test --tests org.gradle.SomeTest.someFeature

//select specific test class
gradle test --tests org.gradle.SomeTest

//select all tests from package
gradle test --tests org.gradle.internal*

//select all ui test methods from integration tests by naming convention
gradle test --tests *IntegTest*ui*

//selecting tests from different test tasks
gradle test --tests *UiTest integTest --tests *WebTest*ui

Read more here http://www.gradle.org/docs/1.10/release-notes#executing-specific-tests-from-the-command-line

like image 197
pditommaso Avatar answered Sep 20 '22 15:09

pditommaso


The correct syntax is:

gradle testTaskName -DtestTaskName.single=...

In this case:

gradle integrationTest -DintegrationTest.single=...

like image 28
Peter Niederwieser Avatar answered Sep 18 '22 15:09

Peter Niederwieser