BT

Thoughts on Test Automation in Agile

Posted by Rajneesh Namta on Feb 21, 2012 |

Working in the time box of a scrum sprint does present some challenges - especially if your team is building a product from scratch. Sprint after sprint you have to add new features and ensure that whatever you built previously continues to work. Having an automated testing framework, which takes care of both system and integration tests, adds a lot of firepower to such a team. It not only acts as a safety net against regressions caused by new development, but more importantly frees up a lot of precious developer and tester time - allowing them to focus on the things they do best.

In this article, I intend to share with you some of the test automation techniques our team successfully implemented on a recent project – the results of which have proven to be a huge asset. Although it took us quite some time to reach where we are now, it’s been well worth the investment and the efforts are paying off in big way. We are now able to build, integrate, test and deploy our application software with production-like quality in a production-like environment every single day. While we had our share of good days and bad days, we managed to learn something new through the experience and apply that learning to make things better.

Our team is very happy with the results we are seeing from applying test automation techniques to our project. Applying these techniques has allowed us to consistently add new features to the product at a very brisk pace with every sprint and has proven to be crucial in finding and fixing critical issues we faced as a result of regressions.

Here are a few of the real life lessons we learned which should keep in you in good stead if you begin adding test automation to your projects.

Start Small

The process you follow when creating automated tests is very similar to the process you follow for creating the software being tested. It involves a fair bit of design, coding and testing of its own to get it working correctly. So just like the application itself, automated tests are best developed incrementally - adding new tests and features to the automation framework over several different sprints. It’s important not to aim for the perfect “it-can-do-everything” test framework right at the start, as it would never materialize. Balance the cost vs. ROI well and come up with a bare minimum working solution at the start. Working tests, just like working software, are useful; they build confidence and get everyone excited about the progress being made. Successes, even small ones, make it easier to bring everyone on-board – especially when the test automation solution you have created actually runs and proves to be of real value to the team.

Test Automation Backlog

Maintain a test automation backlog for your project that contains all needed automation tasks and identified improvements. If you then target a few items from the backlog every sprint, in no time you will start to see the new regression test suite taking shape. Occasionally, stories from the test automation backlog may require dedicated developer time to implement and consequently some buy-in from the product owner in order to proceed. However, it should not be difficult to convince the product owner about the value of such stories if everyone on team is committed to quality.

A test automation backlog could contain a prioritized list of items such as:

  • Parameterize the test environment for test execution.
  • Integrate with Continuous Integration.
  • Enhance reporting mechanism.
  • Provide an option to attach error logs in notification emails.
  • Collect performance metrics for workflow scenarios.
  • Add tests to check for concurrent execution of critical test cases.

Tools Are Just the Means And Not The End

The tools and frameworks you use to achieve test automation are not the real goal of your testing efforts. If you focus on the big picture, the real goal is to support new development efforts by providing rapid feedback to the team. This helps keep everyone informed about the current state of the project so that interested stakeholders can make informed decisions. Since tools and frameworks are only a means to achieve a much broader end, it is important to not get obsessed with the new tools and lose sight of the ultimate goal.

It is also important to keep your tests and test data independent of the selected test automation tool as much as possible. Creating tests with hard-coded test data, system configuration, and properties makes them difficult to maintain. And in the long run, strong coupling with the test data makes it difficult to change your test tooling midway through the project if you were to run into any unanticipated issues.

Create Meaningful Tests and Don’t Try to Automate Everything

The most important part of your test solution is the “tests”. A lot of teams spend most of their time and effort creating a nice framework with lot of features but bereft of any meaningful tests. Don’t let the framework code become more important than the test code. The proposition of creating a state-of-the-art framework is tempting but you should avoid this trap. The real value of any test automation effort is derived from the tests it produces, so stay focused on creating meaningful tests.

Additionally, do not automate for the sake of automation. Due consideration should be given to concerns like maintainability and execution time before adding new tests. Each test the team adds to the automated test suite becomes part of the production code base and therefore must be maintained just like the rest of the code base - for the entire life of the application. Adding tests that are overly complex or difficult to maintain, end up slowing down the feedback cycle to the team and should be avoided.

Get It Out Of Your Local Machine

If you are creating automated tests for your project and the only place where the automation runs is your local machine, the tests are basically of no use. Everyone on the team should benefit from the safety net of tests you have created and to do that you must get the tests off of your local machine.

The automated test suite should be easily accessible by all the team members and everyone should be able to execute it with a push of a button. If someone wants to run the test prior to or after committing a large number of changes, they should be able to run the test suite and get feedback with minimum fuss. Ideally, the automated test suite should be hosted on an external server and wired to run as part of the build process or the continuous integration environment. Schedule the test suite to run frequently (i.e. on every check-in or at least daily) and keep a tab on the status. Have notification mechanisms in place to notify everyone involved of the latest test execution status.

Execution Time Matters

How long the test suite takes to run all of the tests is a critical concern. If the test automation takes too long to execute it ceases to add value since the intended feedback is no longer quick (especially for Agile projects with short iterations). In addition, those running the test suite will quickly stop running them since it is just too painful to have to wait that long. Use parallelism, production like infrastructure, or any other trick in the book - but make your tests run fast so that you can maintain quick feedback cycles.

Additionally, test cases can be tagged and run selectively based on the component/feature being worked on. The ability to run selected tests will save execution time especially if the test suite is fairly large and running the entire test suite doesn’t make real sense in the given context.

Keep It Green

Keep all the tests in your test suite “green” (i.e. running successfully). Sometimes, however, you may have tests that are failing for known reasons. Perhaps part of the system is unavailable or perhaps a fix is under development but may be delayed for some time. In this situation, you might choose to tag these tests in the test suite as “known failures” allowing the test framework to ignore or skip those tests. Doing this will keep the build from failing and other tests executing so that new test failures are immediately visible.

Be disciplined and make it a priority to turn the tests green as soon as they turn red (i.e. fix the tests or fix the code). The sooner you address failed tests, the easier it is to correct them – especially if it was a recent code change that was just checked in which made them fail. Pay attention as well to test suites that never seem to fail since simply having automated tests in place can create a false sense of security. In some cases, adding automated tests to your project can create a sense of insecurity if the tests are brittle and fail frequently. In either case it should provoke some investigation by the team.

Some amount of testing of the test code is recommended to flush out problems, and create confidence that the automated tests are working reliably. Also, it is a good idea to use data fuzzing so that you don’t use the same data for every test execution. This will help to create more robust and meaningful tests.

Precise Reporting

Make it a point to spend some time on the reporting feature of your test framework. Report failures and errors in a clear and concise manner so that people who are investigating them need not spend too much time figuring out what went wrong and where. Keep the reports absolutely simple and make them visual if you can afford to do so.

Make It Visible To Everyone

Last but not the least, keep the process simple and accessible and make the results of test automation visible to all the stakeholders. Have the test history and trends available online and if possible, hook it to a code quality analysis tool like Sonar. Let people look at the results from their perspective. Make it extremely simple to add and update tests and let everyone participate in making it even better.

Summary

To summarize, the test automation techniques we found most effective, and the ones you should pay particular attention to, include:

  • Start small at the beginning of the project and build the test suite iteratively with each passing sprint.
  • Create a test automation backlog to serve as a prioritized list of automation tasks. This will help you stay focused on the immediate tasks without losing sight of the long-term goals. Have a good look at the available testing tools and their capabilities and don’t be afraid to invest a sprint or two in getting your hands dirty with them. This will ensure that you get started with the best available testing options and establish a realistic assessment of their features.
  • Keeping your tests and data loosely bound will help you to switch testing tools with ease in the future if such a need arises.
  • Create meaningful tests and give due consideration to concerns like maintainability and execution time while adding tests to the automation suite.
  • As soon as possible, make every effort to enable the whole team to use the security net you’ve created by putting it on a build/CI system.
  • Create meaningful tests and ensure that they don’t create a false sense of security.
  • Make every effort to resolve test failures quickly and keep test execution times as short as possible.
  • Last but not the least, have an intuitive reporting mechanism in place and give everyone on the team visibility to test results and historical trends. This will help everyone involved in the project monitor the progress and health of development and make more informed decisions.

Conclusion

In this article, I shared many of the lessons my team and I learned while implementing test automation on a recent project. The test automation techniques described in this article are by no means a complete list. They are just a compilation of a few little gems I gathered while implementing test automation with a great team.

It’s important to remember that automating software tests allows computers to do what they do best, rapid execution of regression test suites to verify software functionality over and over again. This allows the people on the team to focus more on what we do best, developing and testing the system using our cognitive skills in an exploratory fashion.

If you follow the techniques recommended in this article and invest in test automation, you too will be able to build, integrate, test and deploy your application software with production-like quality, in a production-like environment, every single day.

About the Author

Rajneesh Namta, a Senior Test Consultant at Xebia India, is passionate about software testing having worked the last 7 years in various software testing related roles. A Certified Scrum Master, Rajneesh has been practicing Agile software development for more than 3 years. He has worked across many different stages of software development including requirements specification, design and development, user acceptance testing, and post-production training. A member of the soapUI product advisory board, Rajneesh loves to participate and contribute to the Agile and testing communities through blogs, articles, and conference speaking engagements.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Congratulations / Other info by Henrique de Miranda Gontijo

Hi,
Congratulations for the article. I think it brings key points to adopt the test automation.

- Have you faced challenges regarding the team (QA, PO and Developers) adoption to test automation? If yes, what was your approach?
- About the tools used, do you mind to share the pros/cons of the tools chosen and discharged?

Thank you,
Henrique

Re: Congratulations / Other info by Rajneesh Namta

Hi Henrique,

Thanks for taking time to go through the article and writing back. As far as your questions are concerned here is what my experience has been so far:

- Have you faced challenges regarding the team (QA, PO and Developers) adoption to test automation? If yes, what was your approach?

This largely depends what kind of environment you are working at. I have been fortunate enough to work at places where quality is given utmost importance and "quality without compromise" has been the motto. I firmly believe that you cannot bake quality into software after it has been created. The process of creating software ultimately manifests itself through the solution as either good or bad.

The process of creating quality software has to be inside out (start at the same time when software development begins) rather than outside in (after it has been finished). Practices like TDD, paired programming/testing, automated builds, continuous integration and automated functional tests are few of the examples which enable us to achieve exactly this.

Hence if your team is already following some of these practices, it should not be a problem to have them on your side when it comes to adopting test automation. Such a team would quickly realize the absence of feedback mechanism and strive hard to have that in place. Product owners, though are keen to get the high priority features in quickly, are also the ones who are going to benefit a great deal from test automation at the first place. Ultimately product owners are the ones who are going to accept the User Stories as done; and once done they would like to focus more on the new stuff coming out rather than losing sleep over what they have already accepted.

In a nutshell, the feedback mechanism is going to help everyone on the team; be it a tester, developer, product owner or even a prospective customer.So if you have a quality culture, you probably have some level of test automation already in place (unit tests?)and it’s easier to build on from there.In case you feel its missing, it’s time to bring about a quality revolution first and test automation will follow sooner than later.

- About the tools used, do you mind to share the pros/cons of the tools chosen and discharged?

Well, the tools chosen largely depend on the context in which they are used. Hence it would not be suitable for me to recommend one over another since the context in which it’s applied may vary. Nonetheless there are a large number of open source test tools which have matured enough over years and can take care of almost all kinds of testing requirements.
You can refer to the AA-FTT spreadsheet (AA-FTT stands for Agile Alliance Functional Testing Tools group) mentioned in this excellent blog post by Elisabeth Hendrickson.
testobsessed.com/blog/2011/12/01/selecting-test...

Regards,
Rajneesh

Good Article by Bhavitha S

Hi Rajneesh,

This is a very good article to start up automation, i guess it has all the points which needs to be considered for automation and was happy to read it through.
Thanks for jotting it down..

No nonsense article by Kalyan Muthiah

This was very helpful! Thanks for writing this

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

4 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT