Cucumber-jvm @after with Appium driver

China☆狼群 提交于 2019-12-11 02:42:17

问题


I'm using cucumber-jvm , and trying to implement global @After method which should be executed only once after all scenario's execution was completed. The @After method should quit the appium driver.

Currently @After hook being executed after each running scenario , and it means that the driver should be created each time from scratch , but I do want to reuse it.

Any help will be much appreciated


回答1:


You can try using QAF which support Gherkin, where driver management is taken care by the framework. It is dedicated framework built upon TestNG for web, mobile web, mobile native, and webservices functional test automation.

When using QAF you don't need to write any code to setup/teardown driver. You can configure as per your need through testng xml configuration file and properties. You can specify behavior by using property selenium.singletone. For example:

#will reuse driver session for close browser after all testcase configured under xml test node
selenium.singletone=true
#will teardown after each scenario/testcase
selenium.singletone=Method
#will reuse driver session for group
selenium.singletone=Groups

If you are running in parrallel it will you can have driver session sharing between test running in same thread. All combinations you can achieve through execution configuration.

Moreover, you can use all TestNG listener and annotations. For example:

  • @BeforeMethod:Invokes Before each Testcase/Scenario
  • @BeforeSuite: Invokes once before entire suite
  • @BeforeTest: Invokes once before each xml test node for each xml test node in configuration
  • @BeforeGroup: Invokes once before starting execution of test in group for each group
  • @AfterSuite: Invokes once after entire suite
  • @AfterTest: Invokes once after entire xml test node
  • @AfterGroup:Invokes once after all test in group for each group
  • @AfterMethod:Invokes after each Testcase/Scenario

Refer Gherkin with QAF



来源:https://stackoverflow.com/questions/53991190/cucumber-jvm-after-with-appium-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!