Java 如何使用命令行在Gradle上运行空手道测试
我正在查看空手道文档: 我的档案如下: 跑步者等级:Java 如何使用命令行在Gradle上运行空手道测试,java,gradle,build.gradle,gradlew,karate,Java,Gradle,Build.gradle,Gradlew,Karate,我正在查看空手道文档: 我的档案如下: 跑步者等级: import org.junit.runner.RunWith; import com.intuit.karate.junit4.Karate; import cucumber.api.CucumberOptions; @RunWith(Karate.class) @CucumberOptions(features = "classpath:feature/country.feature") public class APITest {}
import org.junit.runner.RunWith;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
@RunWith(Karate.class)
@CucumberOptions(features = "classpath:feature/country.feature")
public class APITest {}
将此放置到我的build.gradle:
test {
// pull cucumber options into the cucumber jvm
systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
// pull karate options into the jvm
systemProperty "karate.env", System.properties.getProperty("karate.env")
// ensure tests are always run
outputs.upToDateWhen { false }
}
我试着这样管理gradle:
./gradlew test -Dtest=APITest
但我得到的回应是:
Rafaels-MacBook-Pro:TestProject rafaelpaz$ ./gradlew test -Dtest=APITest
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
但是,我看不出我的测试是否通过。我做错了什么
渐变版本:2.14.1
有一个正在运行的gradle空手道演示项目,请根据您的要求更改.feature文件。
使用:
梯度清洁试验
如果你需要更多信息,请告诉我
谢谢
Sreecharan Shroff你确定你有足够的语法来运行一个测试:@PeterThomas再次感谢帮助Peter,我以前尝试过这些命令,但我成功了,但只有使用JUnit,使用空手道我才会出现如下错误:
失败:生成失败,出现异常。*错误:任务“:测试”的执行失败>找不到给定包含的测试:[org.gradle.APITest]*请尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多的日志输出。
这是我做错了,但仍然没有意识到我帮不了什么忙。伙计,请换成maven。我再次在推特上问你help@PeterThomas好朋友,谢谢你的帮助!我还要做更多的测试!干杯这才是我真正需要的,Sreecharan!非常感谢你的帮助!我接受了你的回答!干杯,伙计!您好@Sreecharan Shroff,我的测试运行成功,但是当我使用gradle命令行运行测试时,我没有看到生成的报告HTML文件,如果您知道这一点,请提供帮助。在gradle中,默认情况下,报告在projectFolder/build/reports中生成。我试过空手道0.9.2,报告生成正确。你可以从上面的链接尝试我的gradle空手道项目。请附上您的项目以复制该问题。