Tips for automated Testing.
- Never write calls that directly interact with the product you are automating, write an interface layer. This way when the product changes you will only have to change a limited number of lines rather then the hundreds that it would be if you have a line clicking a specific link in every script.
- Automate the running of the scripts as much as possible. Make it so all you have to do is click a button or edit a file this way re-batching the scripts is not that big of a deal.
- Never have a literal string in a function call. Even though you pushed every call that actually interacts with the program that you are testing. You will still have the same string called from several locations. When this changes all you have to do is change one string.
-
Never have a navigation function that validates a page. Navigation functions get called more than any other set of functions in a test framework. Putting validation code in them will slow down every script that uses the function. It is much better to have a separate validation function you can call when you really want the page to be validated.
-
When a string literal can be more than one value check for all values and act accordingly, don't just do all possible actions at one time. Even though it seems easier to do this it will take longer and you spend more time handling error conditions.
- When dealing with errors handle them as soon as they appear. If it is an expected error clear it and go on your way. If it is not expected clear the error and do your best to clean up the script work area. Cleaning up all the data and the program before exiting the script. This way you don't kill the following scripts chances of completing successfully.