Wednesday, January 28, 2009

If You Want to Automate Tests, Learn to Script

Many people who get tasked with automating test cases have never written code before. As such, they rely on the promises from UI tool vendors that they can automate all their tests without ever touching a line of code. While UI automation tools may be able to create simple tests, those tests tend to be brittle and prone to breakage. As such, a non-scripting user can quickly become frustrated and abandon test automation all together. Compare that to a person with some scripting experience - they can very easily modify a recorded script and turn it from something brittle into something nearly bulletproof.

When I started out in automation, my background was in technical writing. I had no programming experience or training, but I saw how powerful automation could be, and was determined to see it work. I spent a lot of time learning TSL, which was WinRunner's proprietary language, and found that I could make tests really sing by coding them myself. (My colleagues who were relying on record & playback were astounded that my scripts could recover from errors. )

Eventually, I realized that there were other automatable tasks that fell outside the scope of WinRunner. I learned Python and with that I was able to compare the contents of excel spreadsheets, verify that email messages had been posted to a server and then delete them, automatically reboot systems and put them into the proper state for testing. Those wound up being even bigger timesavers.

So the moral of the story is - if you're going to get into automation, learn how to script. Don't believe anyone who tells you that all your test automation goals can be achieved without ever touching a single line of code. By learning how to script, you become more marketable, and your company's automation efforts have a better chance of success.

There are a lot of great scripting languages out there - Python, Ruby, JavaScript. If there are developers in your company who already know one of them, ask them to recommend a book or website that will help you learn. If you're working with .NET, I highly recommend A Tester's Guide to .NET Programing
and Effective Software Test Automation

1 comment:

  1. Hi Nick. I agree 100%. In fact I have presented on this very topic before. You can find the content at http://adam.goucher.ca/?p=570

    -adam

    ReplyDelete