gpt4 book ai didi

java - CLI runner cucumber.api.cli.Main 找不到步骤定义

转载 作者:搜寻专家 更新时间:2023-11-01 03:17:21 24 4
gpt4 key购买 nike

问题
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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com