の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>
仕様
|-src
|-test
|-java
|-MyFeature1
|-MyFeature1Steps.java
|-MyFeature1Test.java
|-MyFeature2
|-MyFeature2Steps.java
|-MyFeature2Test.java
|-resources
|-Features
|-MyFeature1
|-MyFeature1.feature
|-MyFeature2
|-MyFeature2.feature
MyFeature1Test.java
での複数のステップのファイルに共通のメソッドを実装する、私はこれを持っている
@smoke
Feature: Feature 1
Background:
Given User is Logged in
Scenario:
Given Go to this Page
When Perform this action
手順クラス:
@RunWith(Cucumber.class)
@CucumberOptions(format = { "pretty", "html:target/cucumber", "json:target/cucumber.json" }, features = "classpath:Features" , tags = "@registration", glue={"classpath:MyFeature1/MyFeature2Steps.java"})
public class MyFeature2Test
{
}
シナリオファイルMyFeature2.feature
:
@Abc
Feature: Feature 2
Background:
Given User is Logged in
Scenario:
Given Go to that Page
When Perform that action
もう一つのステップクラス:MyFeature2Steps.java
:
public class MyFeature1Steps
@Given("^User is Logged in$")
public void navigateAndLogin()
{
//Implemention
}
@Given("^Go to this Page$")
public void goToThisPage()
{
//Implemention
}
@Then("^Perform this action$")
public void verifyAbc()
{
//Implemention
}
MyFeature2Test.java
で、私はこれを持っています
public class MyFeature1Steps
@Given("^User is Logged in$")
public void navigateAndLogin()
{
//Implemention
}
@Given("^Go to that Page$")
public void goToThatPage()
{
//Implemention
}
@Then("^Perform that action$")
public void performThis()
{
//Implemention
}
は、だからここに私はすべての手順ファイル(MyFeature1Steps.java
、MyFeature2Steps.java
、など)にバックグラウンド(与えられたユーザーがログインしている)の実装方法(navigateAndLogin()
)を記述する必要があります。
testNGのbeforeAllのような共通の場所に '指定されたユーザがログインしました'というメソッドを書くことはできますか?