与Gradle 4.6的JUnit5集成测试 [英] JUnit5 integration tests with Gradle 4.6

查看:100
本文介绍了与Gradle 4.6的JUnit5集成测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gradle 4.6为JUnit5添加了支持.

Gradle 4.6 added support for JUnit5.

只要我没有其他来源(例如,集成测试:我不知道如何在集成测试中启用useJUnitPlatform().

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.

我能够做的是让test任务与新的JUnit5支持一起工作,但是我的testInt任务正在使用JUnit5控制台并运行测试,因为它将从命令行运行.最后,我放弃了对JUnit5的支持,并回滚到对这两个测试都使用JUnit5控制台.

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.

如何在test之后的其他任务上启用Gradle 4.6 JUnit5支持?

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

推荐答案

如果集成测试任务也是Test任务,则可以通过以下方式配置所有测试任务:

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

tasks.withType(Test) {
    useJUnitPlatform()
}

或明确配置它:

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

这篇关于与Gradle 4.6的JUnit5集成测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆