Skip to content

Running just one Test Class

Roland Stens edited this page Dec 6, 2017 · 3 revisions

Originally found in: https://dzone.com/articles/gradle-goodness-running-single

In order to run just one test class in order to speed up development and testing, run:

gradlew -DchromeTest.single=FlowSpecs chromeTest

This will run just the test class FlowSpecs.

But this method also allows you to run a group of tests as the test class name is interpreted as a wild card.

So: gradlew -DchromeTest.single=Fl chromeTest

Will run all test classes starting with "Fl"

For instance: if you want to make a test suite for smoke testing, you could create test class wrappers like this:

class SmokeFlowSpecs extends FlowSpecs { }
class SmokeClass2Specs extends Class2Specs { }
class SmokeClass3Specs extends Class3Specs { }

Now you can: gradlew -DchromeTest.single=Smoke chromeTest

and all your wrapped smoke test classes are run, using your actual test classes.

So with one code base, you now can combine individual test classes into test suites like: integration, regression, smoke, broken up by functional area etc.