I am building a cloud agnostic spring boot application that has separate cloud provider bean for different cloud providers. These beans are initialised based on the value of a configuration called cloud.provider having possible values aws, ocp, azure & gcp
There is only one class containing test cases that I would like to execute separately for all cloud providers
I have the following structure of classes:
interface CloudProvider {
String process(String input);
}
@ConditionalOnProperty(name = "cloud.provider", havingValue = "aws")
class AwsProvider implements CloudProvider {
String process(String input) {
//process and return aws specific key
}
}
@ConditionalOnProperty(name = "cloud.provider", havingValue = "gcp")
class GcpProvider implements CloudProvider {
String process(String input) {
//process and return gcp specific key
}
}
For which the test cases look something like:
@SpringBootTest(properties = {"mtls.provider=aws"})
class CloudProviderIT {
@Autowired
private CloudProvider provider;
void testProcessForCloudProviders() {
provider.process("input-string");
//Then do some business specific assertions
}
}
The test case remains same for all cloud providers and I don't want to create a new test class for each cloud provider to force recreation of spring context.
Is there a way I could paremeterize @SpringBootTest such that the same class executes but each time with a value from all possible values