空手道:通过命令行传递动态参数值不起作用
Karate: passing dynamic parameter values via the command line not working
当我在命令行上进行 运行 空手道集成测试时,我试图从命令行传递 URL。我看了一下 this 并尝试做同样的事情,但到目前为止没有成功。
我有这个 karate-config.js
文件
function karateconf() {
karate.configure('connectTimeout', 5000);
karate.configure('readTimeout', 5000);
var config = { baseURL: 'http://localhost:8080' };
if (karate.env == 'ci') {
config.baseURL = karate.properties['base.URL'];
karate.log('*******************************', karate.properties['base.URL']);
}
return config;
}
我运行测试使用gradle像这样
./gradlew integrationTest -Dkarate.env=ci -Dbase.URL=http://someurl:8080
这是空手道日志
14:12:54.599 [pool-1-thread-1] INFO com.intuit.karate - ******************************* null
14:12:54.827 [pool-1-thread-1] ERROR com.intuit.karate - url not set, please refer to the keyword documentation for 'url'
14:12:54.827 [pool-1-thread-1] ERROR com.intuit.karate - http request failed: url not set, please refer to the keyword documentation for 'url'
14:12:54.836 [pool-1-thread-1] INFO c.i.karate.cucumber.CucumberRunner - <<<< feature 1 of 1 on thread pool-1-thread-1: com/guidewire/lifecycle/controller/configuration-controller.feature
14:12:55.359 [Test worker] INFO n.m.cucumber.ReportParser - File '/workspace/configuration-service/configuration-infrastructure/app-backend/lifecycle/target/surefire-reports/TEST-com.guidewire.lifecycle.controller.configuration-controller.json' contain 1 features
我不知道我在这里遗漏了什么。
Gradle?这包含在文档中:https://github.com/intuit/karate#command-line - 看起来您需要将 base.URL
添加到您的 gradle 构建文件中,方法如下:
For gradle you must extend the test task to allow the cucumber.options
to be passed to the Cucumber-JVM (otherwise they get consumed by
gradle itself). To do that, add the following:
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 }
}
当我在命令行上进行 运行 空手道集成测试时,我试图从命令行传递 URL。我看了一下 this 并尝试做同样的事情,但到目前为止没有成功。
我有这个 karate-config.js
文件
function karateconf() {
karate.configure('connectTimeout', 5000);
karate.configure('readTimeout', 5000);
var config = { baseURL: 'http://localhost:8080' };
if (karate.env == 'ci') {
config.baseURL = karate.properties['base.URL'];
karate.log('*******************************', karate.properties['base.URL']);
}
return config;
}
我运行测试使用gradle像这样
./gradlew integrationTest -Dkarate.env=ci -Dbase.URL=http://someurl:8080
这是空手道日志
14:12:54.599 [pool-1-thread-1] INFO com.intuit.karate - ******************************* null
14:12:54.827 [pool-1-thread-1] ERROR com.intuit.karate - url not set, please refer to the keyword documentation for 'url'
14:12:54.827 [pool-1-thread-1] ERROR com.intuit.karate - http request failed: url not set, please refer to the keyword documentation for 'url'
14:12:54.836 [pool-1-thread-1] INFO c.i.karate.cucumber.CucumberRunner - <<<< feature 1 of 1 on thread pool-1-thread-1: com/guidewire/lifecycle/controller/configuration-controller.feature
14:12:55.359 [Test worker] INFO n.m.cucumber.ReportParser - File '/workspace/configuration-service/configuration-infrastructure/app-backend/lifecycle/target/surefire-reports/TEST-com.guidewire.lifecycle.controller.configuration-controller.json' contain 1 features
我不知道我在这里遗漏了什么。
Gradle?这包含在文档中:https://github.com/intuit/karate#command-line - 看起来您需要将 base.URL
添加到您的 gradle 构建文件中,方法如下:
For gradle you must extend the test task to allow the cucumber.options to be passed to the Cucumber-JVM (otherwise they get consumed by gradle itself). To do that, add the following:
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 }
}