Being able to identify issues quickly and having an automated system that tells us whether or not the application is broken, sounds like a must have practice for software development companies nowadays. Nevertheless, we are still facing many challenges specially on large and complex systems.
So where do we start?
In my opinion, the first step in getting automated is having a CI (Continuous Integration) system in place and making sure the builds cover major branches.
The CI system needs to be able to deploy and run the application in isolation per branches, for example using different virtual machines / databases. This way we can make sure we have a known state of all resources and that we are able to roll back to that state after the tests run. Having the hardware/software resources needed for this is key to success.
In many cases, we may require changing the way the application is built and deployed, using tools and creating scripts that runs steps automatically in CI.
Being able to run tests automatically in CI
Select the tools that allows you to run automated tests unattended and getting tests results reports in CI. This way we make sure all the tests are executed after every code change, and that we also are able to run many tests on different environments/configurations.
Creating the tests
Get the whole team involved and make the creation of different levels of automated tests a part of development activities. Consider the team may need to improve their code design skills, which leads to testable code. Most of us have heard high cohesion and low coupling, for a long time; unfortunately it is common not seeing these applied.
Automated tests general guidelines
- The test should communicate intent: it should be clear and simple what the test is verifying, and how the functionality is used by the application.
- The test must have an assert.
- The test must pass and fail reliably. The test should not have code branches i.e. if/else statements that cause it to not give a reliable pass/fail.
- If for some reason, the test has code branches, there must not be one that doesn’t have an assert.
- Keep tests independent: As tests grow, running the tests sequentially may be unpractical, so we need to make sure we can run tests in parallel and get quick feedback.
- There must be a way to run separately unit, integration and end to end tests. The distinction between these must be clearly understood.
- Unit tests must run fast.
- Do not comment tests when they start failing, fix them.
This list can grow very long but at least this can be a good start =)
Hope this summary helps you and your team getting automated.
No comments:
Post a Comment