I have Project A
, Project B
, and Project C
, each one deploying a different REST API. I want to smoke test each one after it’s deployed to make sure the REST API is working correctly.
By using Rest-Assured and TestNG, I have a TestFactory
that can create the neccessary tests dynamically, reading values from a json that allow me to configure each test suite accordingly. This is working in Project A locally: I have a source set for smoketests and a task that will create and run the tests.
I would like to create a gradle plugin that would allow me to simply run a task and have the tests be created and ran, without having to repeat my testing setup accross multiple projects. In other words, I want to share the smoketests accross different projects through the creation and usage of a gradle plugin.
So far I managed to run the ´TestFactory´ method through a task from the plugin, but I can’t make gradle run the tests after the classes are instantiated. Is this possible at all?
Basically I would like to do something like the following:
public class SmokeTestFactoryTask extends Test{
private static final List<TestingParameter> testingParameters = new ArrayList<>();
@Inject
public SmokeTestFactoryTask(String region, String stage) {
//Neccessary task configurations (I think this is where I need help)
//The goal would be to retrieve a List of TestingParameter from which to configure the test class.
}
//The end goal is to run this factory from the List, and then have TestNG run the tests it creates
@Factory
public Object[] createGetResponseCodeTest() {
return testingParameters.stream()
.map(RestAssuredTest::new)
.toArray();
}
}