what defines a high quality test?
1.only fails when the SUT fails
2.easy to read
3.fast and reliable
what defines mantainability of tests?
- changes are not frequently needed
- changes are easy to apply
- changes to SUT don’t break your test scenario
- if a change to the SUT breaks a test, it has no butterfly effect on all the tests(each test only tests one specific attribute of the SUT)
how to minimize the impact of change?
- use stable control locator strategy
- Accessibility id
- iOS: accessibility id
- android: content-description
- windows: AutomationId
- XPath: stop using XPath! It is extremely fragile!
- UI Test Recorders: don’t use them, they generate very fragile tests
- Accessibility id
- minimize repetition of code
- minimize the things tested by one test case
- create abstraction bewteen the test and the SUT
patterns & practices for maintainability
- don’t repeat yourself(DRY)
- stop copiying and pasting code, avoid repeating patterns that we use over and over again, move them either to a class or a method)
- single responsibility principle
- when you write a class, then this class should only be responsible for one thing only
- page object pattern
- for each screen/page create a class that abstracts the interaction with the screen/page
- for each action create an action method that returns a page object
- for each verification create a method that executes the verification and returns true or false
- descriptive and meaningful phrases(DAMP)
- read the code as if it is a sentence
- read the code as if it is a sentence
SOLID priciple
S: single responsibility principle
O: open/close principle(create a base class in such a way that when you inherit from the base class, your class is open for extensibility but close for modification by the inheriting class)
L: liskov substitution principle(objects in a program should be replaceable with instances of their subtypes without altering the correctness of the program)
I: interace segregation principle(create specific interfaces that get implemented by concrete classes)
D: dependency inversion principle(you should only depend on abstractions -the interfaces, instead of the concrete implementations)