Gradle test phases?

Is there a way to create custom test phases in gradle?

I have a series of tests, namely

/unit /local /remote 

which runs proven JUnit tests for several different purposes. I would like them to run them as test steps, like gradle test:unit , or something like that. Ideally, I could also provide a description for each phase of testing, so gradle tasks describe the role of each of the tests.

Is it possible? If so, how?

I tried this:

 sourceSets { unit { java.srcDir file('src/test/groovy/local') resources.srcDir file('src/local/resources') } } dependencies {...} task unitTest(type: Test){ testClassesDir = sourceSets.local.output.classesDir classpath = sourceSets.local.runtimeClasspath } 

... as copied from withIntegrationTests in the provided samples, but when I run gradle unitTest , the tests fail.

+4
source share
1 answer

You just need to add three Test tasks ( testUnit , testLocal , testRemote ) and configure them accordingly. (Instead of typing testUnit , you can also reuse the Test task that comes with the Java plugin.) If the sources are in different source folders, it also makes sense to add additional sets of sources. See details in samples/java/withIntegrationTests in the full Gradle distribution.

+5
source

Source: https://habr.com/ru/post/1392964/


All Articles