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
成功地在相同的结构中运行。