When automating user scenarios, we typically cover an end-to-end user flow. Unit testing recommends that each test method should be independant and only test one thing. But things are different in system acceptance testing, as we have to cover a user flow through the application. Consider an ecommerce application where the user visits typically follows the below steps:
- visit homepage
- search for a product
- select the product
- add the product to cart
- click checkout
- sign in
- entery peyment details
- submit order
- wait for confirmation
Now each of these steps need to be verified as we flow through the user journey. So, there is dependency in test methods, e.g. step 3 depends on step 2 which breaks unit testing practice. Also if we put all steps in one test method it is not easy to detect what went wrong if the test failed. And if we wanted to isolate each test method so they are independant of each other, we have to repeat the initial steps over and over again.
What I have done in the past is to use TestNG to provide this dependency on previous test methods. But I wanted to know how do you handle user journeys in your testing?