Cra*_*aig 6 java command-line-interface cucumber cucumber-jvm cucumber-java
问题
Cucumber 在使用 CLI 运行器运行时找不到步骤定义,但在使用 junit 运行器运行时可以找到它。
也就是说,当从 linux 命令行运行黄瓜 jvm 时,找到了特征文件,但没有找到步骤定义文件,产生消息,"Undefined scenarios: src/test/java/com/logic/testing/ClassifyDocuments.feature:8"
(完整消息见底部)
但是,通过 Maven 运行,例如“mvn test”,会找到步骤定义并且测试按预期执行。我已经看过类似的问题,并且在我秃顶之前希望得到任何帮助。
- 文件是否需要以不同的方式组织,例如使用“资源”目录?
- 胶水参数 com.logic.testing 是否不正确?
- 类路径有问题吗?
详细信息
这是在“自动测试”文件夹中发出的命令行语句:
java -cp "/usr/local/bin/cucumber/cucumber-core-1.2.5.jar:/usr/local/bin/cucumber/*:." cucumber.api.cli.Main -g com.logic.testing src/test/java/com/logic/testing/ClassifyDocuments.feature -s
代码的组织方式如下:
auto-test/
src/test/java
com.logic.testing
StepDefinitions.java
ClassifyDocuments.feature
src/main/java
com.logic.testing
AutoTestController.java(包含一个被 StepDefinitions.java 引用的类)
target/test-classes/com/logic/testing/
StepDefinitions.class
target/classes/com/logic/testing/
AutoTestController.class
在 /usr/local/bin/cucumber/ 是:
cucumber-core-1.2.5.jar Cucumber
-java-1.2.5.jar Cucumber
-jvm-deps-1.05.jar gherkin
-2.12.2.jar
ClassifyDocuments.feature 文件:
Feature: Classify documents in a package
As an auditor
I want to use software
So that I don't have to manually identify subdocuments
Scenario: execute workflow case2 test
Given the workflow case2 test can be configured
And I have been authenticated
When two jobs are submitted with different SLA duration
And the jobs are processed
Then the packages with the shorter SLA duration are completed first
Run Code Online (Sandbox Code Playgroud)
StepDefinitions.java 文件:
package com.logic.testing;
import java.io.File;
import org.junit.Assert;
import cucumber.api.java.en.And;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class StepDefinitions {
AutoTestController atc;
@Given("^the workflow case2 test can be configured$")
public void the_workflow_case2_test_can_be_configured() throws Throwable {
atc = new AutoTestController();
atc.log("~Looking for configuration", log_src);
Assert.assertTrue(atc.getAutoTestConfig("workflow_case2"));
}
@When("^two jobs are submitted with different SLA duration$")
public void two_jobs_are_submitted_with_different_SLA_duration() throws Throwable {
Assert.assertTrue(atc.two_jobs_are_submitted_with_different_SLA_duration());
}
@And("^the jobs are processed$")
public void the_jobs_are_processed() throws Throwable {
Assert.assertTrue(atc.processJobs());
}
@Then("^the packages with the shorter SLA duration are completed first$")
public void the_packages_with_the_shorter_SLA_duration_are_completed_first() throws Throwable {
Assert.assertTrue(atc.checkPackageCompletionTimes("QC_CLASSIFICATION", "READY", 10, 300));
}
}
Run Code Online (Sandbox Code Playgroud)
执行命令行语句后返回错误(是的,它确实以“UUUUU”开头):
UUUUU
Undefined scenarios:
src/test/java/com/logic/testing/ClassifyDocuments.feature:8 # Scenario: execute workflow case2 test
1 Scenarios (1 undefined)
5 Steps (5 undefined)
0m0.000s
You can implement missing steps with the snippets below:
@Given("^the workflow case(\\d+) test can be configured$")
public void the_workflow_case_test_can_be_configured(int arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Given("^I have been authenticated$")
public void i_have_been_authenticated() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^two jobs are submitted with different SLA duration$")
public void two_jobs_are_submitted_with_different_SLA_duration() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^the jobs are processed$")
public void the_jobs_are_processed() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^the packages with the shorter SLA duration are completed first$")
public void the_packages_with_the_shorter_SLA_duration_are_completed_first() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5546 次 |
| 最近记录: |