I am working now for more than one year on a test automation project with thousands of lines of code. I started this project on my own, but during the year much more people got involved. Everyone with their own coding-style. We needed to guarantee the quality of the code written by those people. Therefore we introduced Sonar which performs static code analysis and can find violations of standards. The analysis include:
- Coding standards;
- Code duplication;
- Code complexity;
- Potential bugs;
- Code comments;
- Unit Test coverage;
- And more…
Writing test automation code is like doing “normal” development. So you have to apply coding standards, patterns to avoid duplication and reduce complexity, code comments to describe what each function does. Sometimes when testing safety critical systems you have to write unit tests for the test automation code as well.
Sonar gives you insight in all those areas. It became very clear to me that some test automation developers have bad or uncommon practices. (See screenshot of the dashboard)
Sonar gives the ability to fix or resolve those bad habits.
Installing Sonar is fairly easy
Analyzing your project is even more easy and can be done in three ways:
- Sonar Runner
- Ant Task
- Maven Goal
That said, I think the first week of this year was very effective, we have taken the automation code to a higher level.