Hello,
I am creating a Gradle plugin which must, amongst other things, support the execution of tests on a specific environment. Basically, a developer will create a Gradle project, add our plugin and write tests with the JUnit API, then when the developer launches the tests, our plugin will do some manipulations on the test classes (we rely on JUnit API to write the tests but then they are executed on a specific environment without JUnit, on a custom JVM, with Ant scripts, …) and launch an Ant script to execute the tests.
My first intuition was to implement a custom test framework, so instead of using useJUnit()
or useTestNG()
, we could use useOurTestFramework()
. But I did not find a way to plug a custom test framework, neither with the classic way to run tests, nor with the new JVM Test Suite plugin.
Do I miss something? Is there a way to plug a custom test framework?
For the moment I implemented it in a custom task, plugged to the “test” task. This works fine. My concern is that I reuse the test task options (especially includesPattern/excludesPattern) to allow the application developer to use a well-known and documented syntax. But this means using an object of a different task in my task, I am not sure it is a good practice:
Test testTask = (Test) getProject().getTasks().getByName("test");
DefaultTestFilter testFilter = (DefaultTestFilter) testTask.getFilter();
// then I use testFilter.getIncludePatterns() for example
Is there a better way to do this?
Regards