- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to run precondition and postcondition test methods in Cucumber?
We can run precondition and postcondition test methods with the help of @Before and @After hooks in Cucumber.
Example
Feature file.
Feature: Transaction Table Scenario: Verify the monthly transactions Given User is on the Payment Page
Step Definition has methods with hooks @Before and @After. The test method with hook @Before will be executed as a precondition then the test method (naviagteToPayment() method) will run and finally the test method with hook @After which is the postcondition will execute.
Example
@Before public void method1(){ System.out.println("The precondition executed successfully"); } @After public void method2(){ System.out.println("The postcondition executed successfully "); } @Given ("^User is on payment page$") public void navigateToPayment(){ System.out.println ("Payment screen navigation is successful"); }
Advertisements