내 Selenium Java + TestNG 프로젝트에서 Cucumber를 시도하고 있습니다. 일단 빈 단계 정의가있는 .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>