2
我正在爲我的Selenium Java + TestNG項目嘗試Cucumber。 一旦我用空的stepdefinition運行.feature文件,我應該得到一個片段,我可以將粘貼複製到我的步驟定義類。但是我得到了一種奇怪的格式,不能用於開箱即用。來自Cucumber Java TestNG的片段看起來很奇怪
Given
應該是@Given
,對吧? 沒有public void()
。
可能是什麼原因?謝謝。
2 Scenarios (2 undefined)
5 Steps (5 undefined)
0m0.000s
You can implement missing steps with the snippets below:
Given("^User is on Home Page$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
When("^User enters UserName and Password$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
Then("^He can visit the practice page$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
When("^User LogOut from the Application$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
Then("^he cannot visit practice page$",() -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
這是我glue file
package glue;
import java.io.IOException;
import org.testng.annotations.Test;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import cucumber.api.testng.TestNGCucumberRunner;
@Test(groups = "cucumber")
@CucumberOptions(features = "C:\\Users\\workspace\\cucumber\\src\\test\\java\\feature\\logintest.feature",
glue = "C:\\Users\\workspace\\cucumber\\src\\test\\java\\glue\\Glue.java",
plugin = {"html:C:\\Users\\workspace\\cucumber\\logs"})
public class Glue extends AbstractTestNGCucumberTests {
@Test(groups = "cucumber", description = "Runs Cucumber Features")
public void runCukes() throws IOException {
}
}
這是我.feature
文件
Feature: Login
Scenario: Successful Login with Valid Credentials
Given User is on Home Page
When User enters UserName and Password
Then He can visit the practice page
Scenario: Successful LogOut
When User LogOut from the Application
Then he cannot visit practice page
這是我的依賴
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>