JUnit5 integration tests with Gradle 4.6

时光怂恿深爱的人放手 提交于 2019-12-10 11:09:27

问题


Gradle 4.6 added support for JUnit5.

This works for me as long as I don't have another sourceset for e.g. integration tests: I do not know how to enable useJUnitPlatform() in my integration tests.

What I was able to do is to have test task working with new JUnit5 support, but my testInt task was using JUnit5 console and running tests as it would run from command line. At the end I ditch JUnit5 support in gradle and rollback to using JUnit5 console for both tests.

How to enable Gradle 4.6 JUnit5 support on other tasks then test?


回答1:


If your integration test task is also a Test task, you may configure all test tasks via:

tasks.withType(Test) {
    useJUnitPlatform()
}

Or configure it explicitly:

task testInt(type: Test) {
    useJUnitPlatform()
    ...
}


来源:https://stackoverflow.com/questions/50365010/junit5-integration-tests-with-gradle-4-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!