- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
问题
Cucumber 在使用CLI runner 运行时找不到步骤定义,但在使用junit runner 运行时可以找到它。
也就是说,当从 linux 命令行运行 cucumber-jvm 时,找到了特征文件,但没有找到步骤定义文件,生成消息,“未定义场景: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
代码组织如下:
自动测试/
src/test/java
com.logic.testing
StepDefinitions.java
ClassifyDocuments.feature
src/main/java
com.logic.testing
AutoTestController.java(包含一个由 StepDefinitions.java 引用的类)
目标/测试类/com/logic/testing/
StepDefinitions.class
目标/类/com/逻辑/测试/
AutoTestController.class
在/usr/local/bin/cucumber/中是:
cucumber-core-1.2.5.jar
cucumber -java-1.2.5.jar
cucumber -jvm-deps-1.05.jar
小 cucumber -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
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));
}
}
执行命令行语句后返回错误(是的,确实以'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();
}
最佳答案
Cucumber 扫描类路径以寻找胶水。
所以乍一看我会说你的 -cp
是错误的。当从 auto-test
执行时,我希望它包括 ./target/classes/
及其后代而不是 .
.
关于java - CLI runner cucumber.api.cli.Main 找不到步骤定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45022603/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!