【问题标题】:How to configure with gradle running JUnit4 tests with categories using vintage engine of jupiter Junit5 platform如何使用 jupiter Junit5 平台的老式引擎配置带有类别的 gradle 运行 JUnit4 测试
【发布时间】:2020-03-11 21:11:40
【问题描述】:

当我们只有 JUnit4 测试时,我们使用了

test {
    useJUnit{
        excludeCategories "SlowTests"
    }
}

现在迁移到 JUnit5 并且仍然有 JUnit4 测试,我们如何在 JUnitPlattform 中使用它来让标有 JUnit 测试类别的测试输出?

test {
    useJUnitPlatform{
        // ???
    }
}

【问题讨论】:

    标签: junit4 junit5


    【解决方案1】:

    JUnit4的类别根据full class name of the category映射到标签

    所以以下应该可以工作:

    tasks.test {
        useJUnitPlatform {
            includeTags.add("com.acme.Example")
            // or the following to exclude the tag: includeTags.add("!com.acme.Example")
        }
    }
    

    【讨论】:

    • 谢谢,它有效!对于 gradle 语法: test { useJUnitPlatform{ includeTags "com.acme.Example" } } excluceTags 的排除方式相同
    猜你喜欢
    • 2020-07-04
    • 2017-07-31
    • 1970-01-01
    • 2019-06-06
    • 1970-01-01
    • 2017-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多