Hello,
We are shifting our build systems from ANT to gradle. My business need is to invoke a particular test for a particular component/subproject only not for every subproject. How can I achieve this?
For example -
I have a code structure like myCode/components/xyz , myCode/components/abc , myCode/components/hjk and so on
Every folder under components forms a subproject when code is build. When code is build, for each subproject (xyz, abc, hjk) source code is compiled as well junit tests are executed.
Now, my requirement is - When build is run, All tests under subproject xyz and hjk should be executed but for project ‘abc’ only one particular test - MyTestSuite.java gets executed.
One solution could be to remove all the tests but MyTestSuite.java from project ‘abc’. But I can not do that. Firstly I am not the owner of the code, I am just configuring gradle builds for the owner team. Secondly I doubt that team will change the code as well as it is a legacy code plus in ANT they were executing one particular test only MyTestSuite.java. In ANT there was no concept of subprojects and dependencies so executing one particular test from a list of tests was applicable there.
I searched through different links and tried executing below command -
gradle -Dtest.single=MyTestSuite build
This works fine for project ‘abc’ but it fails for other projects with error -
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task’:xyz:test’. > Could not find matching test for pattern:MyTestSuite
I want this property -Dtest.single=MyTestSuite to be applicable only for task test or for project abc and Not for other projects and tasks - :xyz:test, :hjk:test
Please help me understand how the above requirement can be acheived?