使用 gradle 运行单个集成测试 [英] run single integration test with gradle

查看:35
本文介绍了使用 gradle 运行单个集成测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 gradle 的 -Dtest.single 标志运行单个集成测试.我添加了另一个源集 src/integrationTest 并将测试放在那里.我有一个集成测试任务

I'm trying to run a single integration tests using gradle's -Dtest.single flag. I have added another source set, src/integrationTest and put the tests in there. I have an integration test task

task integrationTests(type: Test) {
    dependsOn 'assemble', 'integrationTestClasses'    
    testClassesDir = sourceSets.integrationTest.output.classesDir
    classpath = sourceSets.integrationTest.runtimeClasspath
}

这运行良好,但如果我尝试运行单个测试,它会告诉我找不到匹配的测试.我不想每次编写新的集成测试时都必须运行每个集成测试.有没有办法做到这一点?

This runs fine, but if I try to run a single test it tells me it cannot find a matching test. I don't want to have to run every integration test each time I am writing a new one. Is there a way to do this?

推荐答案

正确的语法是:

gradle testTaskName -DtestTaskName.single=...

在这种情况下:

gradle integrationTest -DintegrationTest.single=...

这篇关于使用 gradle 运行单个集成测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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