Open GavinRay97 opened 2 years ago
/cc @stuartwdouglas
Easier said than done, but maybe something like:
DevServicesBase
DevServicesDatasourceProcessor
and others like the Mongo processor extend itDevServicesBase
, have some method like:@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.Type)
public @interface DevService {
public String service();
public Map<String, Object> config() default Map.of();
}
abstract class DevServicesBase {
List<DevService> getDevServicesEnabledForClass(Class<?> clazz) {
List<DevService> devServices = new ArrayList<>();
if (clazz.isAnnotationPresent(DevService.class)) {
DevService devService = clazz.getAnnotation(DevService.class);
devServices.add(devService);
}
// Handle inherited classes/interfaces, etc
return devServices;
}
}
@QuarkusTest
@DevService(
service = "datasource",
config = {
@DevService.Config(key = "datasource-name", value = "postgres1"),
@DevService.Config(key = "image-name", value = "postgres:14"),
@DevService.Config(key = "port", value = "5432"),
}
)
class PostgresTest {}
Description
I have an unusual application, it provides support for a very large number of datasources. So in my deps, I have:
Obviously, it wouldn't be good to start half a dozen Docker container services for every dev/test run. So for now, I'm using manual Testcontainers in my tests:
It would be nice to be able to annotate or tag my tests somehow to still be able to benefit from DevServices, maybe something like:
Implementation ideas
No response