1
specification
|-src
  |-test
    |-java
      |-MyFeature1
        |-MyFeature1Steps.java 
        |-MyFeature1Test.java
      |-MyFeature2
        |-MyFeature2Steps.java 
        |-MyFeature2Test.java
    |-resources
      |-Features
        |-MyFeature1
          |-MyFeature1.feature
        |-MyFeature2
          |-MyFeature2.feature

MyFeature1Test.java,我有这个:

@RunWith(Cucumber.class)
@CucumberOptions(format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, features = "classpath:Features" , tags = "@registration", glue={"classpath:MyFeature1/MyFeature1Steps.java"})

public class MyFeature1Test
{   
}

场景文件MyFeature1.feature

@registration
Feature: Login and Registration tests

   Background: 
   Given User is on Sign In Page

   # 1 Register using Username and password
   Scenario Outline: 
      Given User clicks on Sign Up
      And User fills the details
      When User provides "new" email
      And User activates the account
      And Configures password
      Then User should be registered

pom.xml的如下:

   <dependency>
     <groupId>info.cukes</groupId>
     <artifactId>cucumber-java</artifactId>
     <version>1.1.8</version>
     <scope>test</scope>
   </dependency>

    <dependency>
       <groupId>info.cukes</groupId>
       <artifactId>cucumber-core</artifactId>
       <version>1.1.8</version>
       <scope>test</scope>
    </dependency>

     <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.1.8</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-jvm-deps</artifactId>
        <version>1.0.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>1.1.8</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>gherkin</artifactId>
        <version>2.12.2</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

当我使用 maven 运行运行程序文件时,我总是得到如下结果:

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.641 sec - in TestSuite

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

通过 Eclipse 运行也会显示输出为:

@registration
Feature: Login and Registration tests

0 Scenarios
0 Steps
0m0.000s

我在这里做错了什么,因为我能够MyFeature2.feature成功地在相同的结构中运行。

4

2 回答 2

2

我可以在这里看到一些潜在的问题:

  1. glue参数应指向 Java 包,而不是目录。所以像glue = {"com.test.functional.gluecode..."}
  2. 您的场景定义不正确。Scenario Outline当您想要创建多个重复场景同时为Examples表中的每个场景提供输入数据时使用。例如:

.

  Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |  12   |  5  |  7   |
    |  20   |  5  |  15  |

在您的情况下,将其更改为 just Scenario

于 2016-07-26T01:02:42.757 回答
0

将功能文件中的场景大纲更改为场景

点胶参数到步骤定义包

于 2017-02-10T19:44:50.467 回答