使用带有硒的黄瓜-jvm时无法运行方案

时间:2016-07-25 16:28:09

标签: selenium-webdriver cucumber automated-tests cucumber-junit cucumber-java

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运行runner文件时,我总是得到结果:

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

2 个答案:

答案 0 :(得分:2)

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

  1. glue参数应指向Java包,而不是目录。像glue = {"com.test.functional.gluecode..."}
  2. 这样的东西
  3. 您的方案未正确定义。如果要在Scenario Outline表中为每个方案提供输入数据时创建多个重复方案,则使用Examples。例如:
  4.   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  |
    

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

答案 1 :(得分:0)

将要素文件中的方案大纲更改为方案

点胶参数到步骤定义包