首页 > 解决方案 > 没有 maven 的 Cucumber java 项目 - 如果我有 Runner 类,如何从命令提示符运行

问题描述

我有一个跑步者课程,其中有我需要运行的标签。同样的工作完美,因为它选择了需要执行的功能

跑步者类看起来像

package test.java.cucumber.policy;

    import com.github.mkolisnyk.cucumber.runner.ExtendedCucumber;
    import com.github.mkolisnyk.cucumber.runner.ExtendedCucumberOptions;
    import cucumber.api.CucumberOptions;
    import cucumber.runtime.ClassFinder;
    import cucumber.runtime.RuntimeOptions;
    import cucumber.runtime.io.MultiLoader;
    import cucumber.runtime.io.ResourceLoader;
    import cucumber.runtime.io.ResourceLoaderClassFinder;
    import gherkin.Main;
    import org.junit.runner.RunWith;

    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;

    @RunWith(ExtendedCucumber.class)


    @ExtendedCucumberOptions(
                    retryCount = 0)

    @CucumberOptions(glue = {"test.java.steps"},
                    features = {"src/test/resources/features/policy/shakedown"},
                  tags = {"@test"}

    )
    public class ShakedownRunner {



    }

当我尝试从命令提示符运行相同的命令时,我收到未找到步骤定义错误消息。

我正在使用以下命令从命令提示符执行

java -cp "extlib/*;." cucumber.api.cli.Main -p pretty -g C:\21stNov\src\test\java\steps\common\BrowserSteps.java C:\21stNov\src\test\resources\features\policy\shakedown\test.feature

On executing i am getting that the step definitions are missing. Can somebody look into this and provide his valuable comments

#Shakedown Test 1
  @Shakedown @Shakedown1 @rajat
  Scenario: SHD_001_1-Portal SE Quote to GW and check quote documents ←[90m# C:/21stNov/src/test/resources/features/policy/shakedown/test.feature:6←[0m
    ←[33mGiven ←[0m←[33mI start the web browser←[0m

1 Scenarios (←[33m1 undefined←[0m)
1 Steps (←[33m1 undefined←[0m)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^I start the web browser$")
public void i_start_the_web_browser() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

提前致谢..!

标签: cucumbercommand-line-interfacecucumber-java

解决方案


这个问题可能与这个问题重复: 如何从命令行运行黄瓜文件

根据答案,您可以cucumber-jvm在命令行上运行它,如下所示:

java -cp <classpath> cucumber.api.cli.Main \
   --glue com.example.test \
   --plugin pretty path/to/features

推荐阅读