Leaving abstraction out of the test layer can in time lead to duplication of the logic as well as having to spend more time than what is required to script new scenarios. This post will discuss how the test layer can be abstracted and decomposed using TestNG.
High-level Steps
- Start with designing and implementing test cases so that they are atomic
- Encapsulate the test layer by scripting the test steps and adding assertions required to validate the component. Then put a mechanism in place to read the test data from an object that can be passed from one test class to another as required.
- Finally, use the Factory feature in TestNG to compose the larger scripts using the test classes.
- Validate that the dropdown page loads the dropdown and that the values are as expected.
- Validate that the dropdown allows the user to select the option he wants to select.
Test Class 1
Test Class 2
Factory Class
[1] - https://the-internet.herokuapp.com/dropdown
[repo] - https://github.com/handakumbura/SeleniumAutomationEmployerProfile/tree/feature/atomic_test_cases