带自定义测试配置的@QuarkusTest在Maven test中无法执行
问题:带自定义测试配置的@QuarkusTest测试用例在Maven中未执行
执行mvn test时,带有自定义测试配置的@QuarkusTest测试类能够被识别,但类中所有测试用例均未执行——既未被跳过也未被忽略。
自定义测试配置代码如下:
/** * Create a test profile to provide config values only for this test */ public static class EventSenderTestProfile implements QuarkusTestProfile { public EventSenderTestProfile() { } /** * Returns additional config to be applied to the test. This * will override any existing config (including in application.properties), * however existing config will be merged with this (i.e. application.properties * config will still take effect, unless a specific config key has been overridden). */ public Map<String, String> getConfigOverrides() { return Map.of( "prop1", "dummy", "prop2", "dummy" ); } /** * Returns enabled alternatives. * * This has the same effect as setting the 'quarkus.arc.selected-alternatives' config key, * however it may be more convenient. */ public Set<Class<?>> getEnabledAlternatives() { return Collections.emptySet(); } /** * Allows the default config profile to be overridden. This basically just sets the quarkus.test.profile system * property before the test is run. * */ public String getConfigProfile() { return this.getClass().getName(); } }
环境与现象细节
- 使用Java 11、
maven-surefire-plugin:3.0.0-M5 - 在Intellij IDEA中单独运行这些测试用例可正常通过,但Maven日志显示测试用例未执行
- 另一个不带自定义测试配置的
@QuarkusTest运行正常 - 若将作为静态内部类的自定义配置移到单独文件,测试用例会被识别但会被跳过
- 部分
@QuarkusTest因配置属性问题启动失败
疑问:这是否意味着Quarkus测试无法使用自定义测试配置?
内容的提问来源于stack exchange,提问作者WesternGun
相关产品推荐
相关产品推荐

