Tuesday, August 28, 2012

Best practices


Here is my list of best practices for a successful test automation project: 

Maintainability
This is the most important thing to keep in mind - always think about maintainability of your test scripts. If you don't keep this in mind from the beginning of your project, then you will run in to major problems and maintenance of test scripts will take a lot of time  when your test suite is getting bigger.
 
Modularity and reusability
By creating modules / functions will help maintaining your scripts and keep the scripts more simple and understandable.
 
Readable and simple
Write your tests so that they are readable and as simply as possible. This makes it easy for other persons than only you to understand what the script does and why, and it also helps maintaining the scripts.
 
Easy
Tests should be easy to understand, modify and extend.

Addressing components
Never address any components directly in your scripts i.e. don't hardcode any values in your test scripts. Keep variables and parameters in a separate place. This is very important for the maintainability of your tests. 

Independent
Tests should be independent i.e. not depending on any other script.
 
Write "Test to Fail"
When writing tests you should always keep in mind that they might / will fail and they should always be able to handle the failure and do necessary things so that the failure won't affect any following scripts e.g log out, close application.
 
Use GUI element IDs
In web applications use GUI element IDs to locate a component on a page. It will make your scripts more tolerant to changes e.g .changing page layout won't affect your scripts. If components are missing ID's - ask developers to add them.

Use facades
 Don't access APIs directly from your scripts, use some sort of facade. In case API changes, it is easier to make the changes in the facade, than in all the hundreds of test scripts.

Easy debugging
Make it easy to debug failures e.g take screenshots, HTML captures, save system logs in case of failure.

Efficient scripts
Tests should be efficient i.e. run in a reasonable amount of time. Don't make scripts that will take half an hour to run.

Traceability
It should be traceable what part of code and what requirement each test script is testing, otherwise you will later run in to this question - what is this script testing and why?
  

No comments:

Post a Comment