You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

带自定义测试配置的@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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 08:12:27