Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle run only one test suite

Tags:

java

junit

gradle

I have multiple classes under tests using junit and gradle. When I run "gradle test", all my classes are tested. How can I run just one test file?

like image 206
poiuytrez Avatar asked Jul 10 '15 15:07

poiuytrez


People also ask

How do I run a single test case using Gradle?

single system property can be used to specify a single test. You can do gradle -Dtest. single=ClassUnderTestTest test if you want to test single class or use regexp like gradle -Dtest. single=ClassName*Test test you can find more examples of filtering classes for tests under this link.

How do I run a specific module in Gradle?

You can use task's fully qualified name to execute a specific task in a specific subproject. For example: gradle :services:webservice:build will run the build task of the webservice subproject. The fully qualified name of a task is simply its project path plus the task name.

How do I run a single test case in Java?

If we want to execute a single test class, we can execute the command mvn test -Dtest=”TestClassName”. As the output shows, only the test class we've passed to the test parameter is executed.


2 Answers

You can run a single test file from the cli like this:

gradle test --tests org.gradle.SomeTest

You can also run just a particular test method in a similar way:

gradle test --tests org.gradle.SomeTest.someSpecificFeature
like image 79
OlgaMaciaszek Avatar answered Oct 18 '22 23:10

OlgaMaciaszek


You need to use test.single system property. Have a look at this article.

like image 43
Opal Avatar answered Oct 18 '22 21:10

Opal