来自cumberjavatestng的代码片段看起来很奇怪
我正在尝试我的SeleniumJava+TestNG项目。 一旦我运行带有空stepdefinition的.feature文件,我应该会得到一个代码片段,我可以将它复制粘贴到我的stepdefinition类中。但我有一种奇怪的格式,不能开箱即用来自cumberjavatestng的代码片段看起来很奇怪,java,selenium,cucumber,testng,bdd,Java,Selenium,Cucumber,Testng,Bdd,我正在尝试我的SeleniumJava+TestNG项目。 一旦我运行带有空stepdefinition的.feature文件,我应该会得到一个代码片段,我可以将它复制粘贴到我的stepdefinition类中。但我有一种奇怪的格式,不能开箱即用 Given应该是@Given,对吗? 没有public void() 原因可能是什么?多谢各位 2个场景(2个未定义) 5个步骤(5个未定义) 0m0.000s 您可以使用以下代码段实现缺少的步骤: 给定(“^User位于主页$”,()->{ //在
Given
应该是@Given
,对吗?
没有public void()
原因可能是什么?多谢各位
2个场景(2个未定义)
5个步骤(5个未定义)
0m0.000s
您可以使用以下代码段实现缺少的步骤:
给定(“^User位于主页$”,()->{
//在这里编写代码,将上面的短语转化为具体的行动
抛出新的PendingException();
});
当(“^User输入用户名和密码$”时,()->{
//在这里编写代码,将上面的短语转化为具体的行动
抛出新的PendingException();
});
然后(“^他可以访问练习页$”,()->{
//在这里编写代码,将上面的短语转化为具体的行动
抛出新的PendingException();
});
当(“^User LogOut from the Application$”时,()->{
//在这里编写代码,将上面的短语转化为具体的行动
抛出新的PendingException();
});
然后(“^他不能访问练习页$”,()->{
//在这里编写代码,将上面的短语转化为具体的行动
抛出新的PendingException();
});代码>您正在使用cucumber-java8依赖项,因为下面是StepDefinition文件的格式(请确保您的java编译器版本应为1.8)
@给定的注释将使用java语言
给定的注释将使用cumber-java8
import cucumber.api.java8.En;
public class stepDefinitions implements En{
public stepDefinitions(){
Given("^User is on Home Page$", () -> {
// Write code here that turns the phrase above into concrete actions
System.out.println("Test1");
});
When("^User enters UserName and Password$", () -> {
// Write code here that turns the phrase above into concrete actions
System.out.println("Test2");
});
Then("^He can visit the practice page$", () -> {
// Write code here that turns the phrase above into concrete actions
System.out.println("Test3");
});
When("^User LogOut from the Application$", () -> {
// Write code here that turns the phrase above into concrete actions
System.out.println("Test4");
});
Then("^he cannot visit practice page$", () -> {
// Write code here that turns the phrase above into concrete actions
System.out.println("Test5");
});
}
}
我在我的机器上执行了它的工作,尝试一下,让我知道它是否适合你
链接供参考: