通过命令行黄瓜maven

问题描述 投票:0回答:2

我在尝试通过命令行执行我的 maven cucumber-JVM 项目时遇到困难,该项目在 eclipse 环境中运行良好,但我犯了一个非常愚蠢的错误。有人可以指出这可能是什么吗,我将附上下面错误的图像,

<mainClass>cucumber.api.cli.Main</mainClass>
            <includePluginDependencies>true</includePluginDependencies>
            <arguments>
                <argument>--format</argument>
                <argument>junit:target/cucumber-junit-report/allcukes.xml</argument>
                <argument>--format</argument>
                <argument>pretty</argument>
                <argument>--format</argument>
                <argument>html:target/cucumber-html-report</argument>
                <argument>--tags</argument>
                <argument>@kings</argument>
                <argument>--glue</argument>
                <argument>com/Science_Ware/Bilal/KingsPostLogin/</argument>
                <argument>src/test/resources</argument>

            </arguments>

上面是我的 pom.xml 文件和我的类目录,我觉得可能有错误。我的功能文件位于 src/test/resources 中,我的步骤类路径是 com.Science_Ware.Bilal.KingsPostLogin,我的类名也是 KingsPostLogin。

C:\Users\********\My Documents\EclipseWork\Science-Ware>mvn exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Science-Ware 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.3.2:java (default-cli) @ Science-Ware ---
[WARNING] Warning: killAfter is now deprecated. Do you need it ? Please comment
on MEXEC-6.
Feature: Login and clicking on Content Containers

  In Order to Work in Microsoft
  I want to log in
  and verify content containers

  @kings
  Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki
ngsPostLogin/kingspostlogin.feature:7←[0m
    ←[36mGiven ←[0m←[36mI am logged into system on "Mozilla"←[0m
    ←[36mAnd ←[0m←[36mI click on "<Content_Container>"←[0m
    ←[36mThen ←[0m←[36mProcess should be "<Expected_Result>"←[0m

    Examples:

  @kings
  Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki
ngsPostLogin/kingspostlogin.feature:15←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "OrderCentre"←[0m
    ←[33mThen ←[0m←[33mProcess should be "OrderCentreTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse   ←[90m# com/Science_Ware/Bilal/
KingsPostLogin/kingspostlogin.feature:16←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "AggregateOrders"←[0m
    ←[33mThen ←[0m←[33mProcess should be "AggregateOrdersTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse   ←[90m# com/Science_Ware/Bilal/
KingsPostLogin/kingspostlogin.feature:17←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "FreeFormatOrder"←[0m
    ←[33mThen ←[0m←[33mProcess should be "FreeFormatOrderTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki
ngsPostLogin/kingspostlogin.feature:18←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "GetAQuote"←[0m
    ←[33mThen ←[0m←[33mProcess should be "GetAQuoteTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse     ←[90m# com/Science_Ware/Bila
l/KingsPostLogin/kingspostlogin.feature:19←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "ComputerEquipment"←[0m
    ←[33mThen ←[0m←[33mProcess should be "ComputerEquipmentTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki
ngsPostLogin/kingspostlogin.feature:20←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "Oligos"←[0m
    ←[33mThen ←[0m←[33mProcess should be "OligosTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse ←[90m# com/Science_Ware/Bilal/Ki
ngsPostLogin/kingspostlogin.feature:21←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "eTracker"←[0m
    ←[33mThen ←[0m←[33mProcess should be "eTrackerTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse    ←[90m# com/Science_Ware/Bilal
/KingsPostLogin/kingspostlogin.feature:22←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "BrowseCategories"←[0m
    ←[33mThen ←[0m←[33mProcess should be "BrowseCategoriesTitle"←[0m

  @kings
  Scenario Outline: Loggin in Science Warehouse   ←[90m# com/Science_Ware/Bilal/
KingsPostLogin/kingspostlogin.feature:23←[0m
    ←[33mGiven ←[0m←[33mI am logged into system on "Mozilla"←[0m
    ←[33mAnd ←[0m←[33mI click on "BrowseSuppliers"←[0m
    ←[33mThen ←[0m←[33mProcess should be "BrowseSuppliersTitle"←[0m

9 Scenarios (←[33m9 undefined←[0m)
27 Steps (←[33m27 undefined←[0m)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^I am logged into system on \"(.*?)\"$")
public void i_am_logged_into_system_on(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Given("^I click on \"(.*?)\"$")
public void i_click_on(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

@Then("^Process should be \"(.*?)\"$")
public void process_should_be(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

上面是我的命令行执行,它不会调用我的任何步骤方法。他们只是运行而没有任何输出。我正在使用 mvn exec:java 命令来执行。

java eclipse maven command-line cucumber-jvm
2个回答
1
投票

我认为有两个问题。首先,您可能不应该从命令行运行 cucumber。要运行它们,只需添加一个单元测试,如下所示:

import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(
    // Enable one of these to run just some tests. Put regexp to match features in here.
//    name = {"^Preview"},
//    name = {"^Save"},
//    tags = { "@questionLibrary", "@addingCategory" },
    format = {"html:target/cucumber-html-report", "pretty:target/cucumber-json-report.json"},
    strict = true
)
public class RunCukesTest {
}

当 Maven 运行测试时,Cucumber 测试运行器将找到所有功能,创建一个漂亮的 JUnit 测试套件并运行它。这样,问题就会显示为测试失败。

第二个问题是 Cucumber 在你的测试中发现了错误并报告了它们。您需要仔细阅读输出以了解问题所在,然后修复您的功能描述和/或支持代码。


0
投票

我认为

com/Science_Ware/Bilal/KingsPostLogin
正在测试班。

如果是这种情况,你需要通过指定classpathScope让maven知道包括测试类路径

https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-or-java-change-classpath-scope.html

        <configuration>
          ...
          <classpathScope>test</classpathScope>
          ...
        </configuration>
© www.soinside.com 2019 - 2024. All rights reserved.