在Gradle中,你可以使用`exclude`配置来排除包含指定关键字的所有测试用例。首先,你需要在`build.gradle`文件中添加JUnit 5的依赖:\n\ngroovy\ndependencies {\n testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'\n testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'\n}\n\n\n然后,你可以使用`test`任务的`filter`属性来指定要排除的测试用例的关键字。在下面的示例中,我们将排除所有方法名中包含`exclude`的测试用例:\n\ngroovy\ntest {\n filter {\n excludeTestsMatching '.*exclude.*'\n }\n}\n\n\n最后,运行`gradle build`命令时,Gradle将会排除所有方法名中包含`exclude`的测试用例。


原文地址: https://www.cveoy.top/t/topic/pP2n 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录