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?
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.
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.
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.
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
You need to use test.single
system property. Have a look at this article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With