As a tester, i have spent more than 6 years trying to automate tests at the UI layer. As years passed, better automation frameworks evolved resulting in writing more manageable and maintainable code, but the only thing that wasn't getting better was the cost of maintaining these tests, especially when the no. of tests were 500+. There are multiple reasons why i feel creating an automated regression suite of tests at the UI layer is not good. Some of them are
So, we decided to try the model where we would test the business logic. The project where we wanted to try this concept had a Service Oriented Architecture. So basically, the business logic was driven by services and there was a dumb UI that would consume these services. The plan was to automate realistic end to end business flows using a combination of services. As it turned out, this concept worked really well for us.
Some reasons why this concept worked for us are
- Limitations on what the tool can do
- Time taken to execute these tests leading to longer feedback loop
- Success rate of tests is not 100% due to latency issues
- Change in UI and UI flow resulting in an increase in cost to maintain UI tests
So, we decided to try the model where we would test the business logic. The project where we wanted to try this concept had a Service Oriented Architecture. So basically, the business logic was driven by services and there was a dumb UI that would consume these services. The plan was to automate realistic end to end business flows using a combination of services. As it turned out, this concept worked really well for us.
Some reasons why this concept worked for us are
- No limitations of the tool. Absolutely anything could be automated since all we had to do is send a request to the service, and use a part of the response along with further parameters to pass to the next service request and then make assertions where necessary.
- Test execution time is 100 times faster than that of UI tests. Latency is not an issue here.
- No inconsistencies in test pass rate. Tests would fail only when defects were introduced.
- As Testers were consuming these services, they were like customers of the service, which led to driving changes in service design
- Language and technology is same as what the developers use to unit/integrate test the services
- Test failures could be fixed by any developer
- Developers would run the entire regression suite of tests before checking in as the execution time of tests was very fast
- Most stories would be split into service and UI where the devs would first pick the service part. Testers would start automating tests in parallel while the UI part was being plugged into the service. This resulted in the service tests almost being complete by the time the UI part would be complete.
- Developers would contribute a lot in the design aspect of the automation framework which made writing tests more manageable and maintainable.
I agree with Vijay that business logic should be tested at the lowest layer possible, for example the services and then the higher layer tests focus on ensuring data is passed and received correctly. With Ajax heavy applications or rich clients that have business logic built into the UI layer then the UI needs extensive testing. As testers we should work with the development team to ensure the design is testable and I think reducing the amount of business logic in the UI layer is definitely one way of making the design more testable.
ReplyDelete