0
Q
如何在黄瓜中使用
A
回答
1
这个例子是从ToolsQA
采取让我们做黄瓜钩的一些简单的小例子,是想了解这个概念。
Feature: Test Hooks
Scenario: This scenario is to test hooks functionality
Given this is the first step
When this is the second step
Then this is the third step
步骤定义
package stepDefinition;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class Hooks_Steps {
@Given("^this is the first step$")
public void This_Is_The_First_Step(){
System.out.println("This is the first step");
}
@When("^this is the second step$")
public void This_Is_The_Second_Step(){
System.out.println("This is the second step");
}
@Then("^this is the third step$")
public void This_Is_The_Third_Step(){
System.out.println("This is the third step");
}
}
**** ***注:没有在步骤定义中使用的逻辑。只需打印步骤摘要记录即可。*
现在挂钩出现在图片中,在您的情况下,您会想要在此初始化驱动程序。
鱼钩
package utilities;
import cucumber.api.java.After;
import cucumber.api.java.Before;
public class Hooks {
@Before
public void beforeScenario(){
System.out.println("This will run before the Scenario");
}
@After
public void afterScenario(){
System.out.println("This will run after the Scenario");
}
}
确保包import语句应该是进口cucumber.api.java.After; & import cucumber.api.java.Before; 经常有人误会并导入Junit Annotations,所以要小心这个。
Aparts的,你可以利用其它有用的注释黄瓜,请参考上ToolsQA.com here教程。
相关问题
- 1. 如何在黄瓜中使用钩子?
- 2. 如何用黄瓜
- 3. 如何用黄瓜
- 4. 如何学习/教小黄瓜黄瓜
- 5. Node.js BDD。黄瓜,小黄瓜或黄瓜?
- 6. 如何使黄瓜使用,硒和java
- 7. 硒,黄瓜和小黄瓜
- 8. 是否有在黄瓜和小黄瓜中使用标签的最佳做法?
- 9. 使用JavaEE设置黄瓜
- 10. 使用click_link黄瓜方案
- 11. 使用SOAP UI执行黄瓜(小黄瓜脚本)?
- 12. 使用黄瓜-html记者与Nightwatch黄瓜意外结束
- 13. 黄瓜
- 14. 黄瓜
- 15. 如何测试与黄瓜
- 16. 如何写黄瓜测试?
- 17. 黄瓜 - 如何在步骤定义中使用方法
- 18. 如何使用黄瓜在rails中测试OpenID
- 19. 如何在黄瓜步骤中使用锚点访问路径?
- 20. 黄瓜红宝石 - 黄瓜表达式
- 21. 如何使黄瓜场景失败
- 22. 如何使断言黄瓜与硒
- 23. 如何实施'如果'在小黄瓜
- 24. 在黄瓜使用标签选项
- 25. 如何用黄瓜和阿鲁巴
- 26. 如何找到用黄瓜水豚
- 27. 如何重用黄瓜功能
- 28. 如何用黄瓜特征文件
- 29. 如何下载用于编写小黄瓜场景的黄瓜测试工具
- 30. 如何写常见的小黄瓜的考虑,而且,当时在黄瓜
这是一个非常广泛的问题,除了提供有关Cucumber的@Before文档的链接之外,我猜这些问题在当前表单中不可回答。你有没有尝试过可以发布的代码?你想用什么语言,甚至? –