We are developing a large test suite which is intended to run on multiple environments, such as smoke, performance, full suite, etc. (We are currently using JUnit as the test framework.) What we are trying to achieve is annotate tests (classes or methods or both) with one or more annotations like @SmokeTest
, @PerformanceTest
, @AcceptanceTest
and then add some test tasks in the build.gradle
to run a specific selection of tests based on those annotations. The idea is very much like this one from the Gradle forum.
I know Gradle can detect JUnit tests based on JUnit annotations (see 23.12.4. Test detection in the gradle user guide). However, I cannot find out how I can leverage that capability and add some custom logics of my own. What I am looking for is something like below:
- Detect the tests based on one or more given annotations (include or exclude)
- Add the detected tests into a container of some sort.
- Have a test task to run tests in the container.
So, I would like to ask any guidance that you can provide to achieve that functionality. Thank you very much.