Here at Adept Labs we certainly have a language preference. This isn’t meant to imply that there is only a single correct option. The internet is already full of wars over this very subject, and I’m not here to tell anyone that they must feel exactly the way that I do when picking a language for a new project. With that said, this is the first of several posts that will help explain some of the benefits of choosing Python for test automation.
Now, only in rare cases have I experienced the opportunity to start from the ground up on test automation. There is generally a healthy amount of legacy code that no one wants to throw away (or sometimes no one knows how it actually works and you can’t afford to spend the time to figure it out). Sometimes even when a new test automation project starts there are company politics at play that “encourage” the use of some tools that have been chosen as standard. These are all the reality of real business operations. However, knowing the benefits of the options available is only positive. So let’s dive into why Adept Labs has come to standardize on Python for test automation frameworks wherever possible.
I’m going to gloss over the benefits of the language itself, since there are ample resources out there explaining what draws people to it. Instead I’m going to focus on what you should care about when planning a test automation project.
1. Testers are not (usually) developers
It’s true. Despite the popularity of Agile, Scrum and “cross-functional teams”, there is a distinct skill-set that produces a good tester. It requires a different perspective on the product to pick it apart like a good tester does. So the language you put in front of them needs to be easy to learn, quick to start, and come with plenty of packages for common operations. Testers won’t want to reinvent the wheel, and with python they don’t have to. I’m continually surprised when I want to do something seemingly complex — and I find a well-maintained python library that just works.
It’s a perfect fit. Testers want to test, not write piles of boiler-plate code. In addition (or corollary to) Python’s fantastic and growing set of available utilities is its ease of use. Python code is clean and readable to beginners, compared to many languages, and has been growing in popularity in beginning Computer Science courses as a good starter language that gets the concepts clear right away, without slapping you in the face for missing a semicolon (of course you might argue with me that missing whitespace is easier than missing a semicolon, but that’s another discussion completely). Why do you think the Raspberry Pi chose Python as its recommended language?
2. Python is Fast
Fair enough, Python is interpreted (well, byte-compiled to be more accurate), and it will lose to optimized code in some other languages. But you’re not going to write test automation in assembly. I’m talking about speed of getting working code in place. In this application, you will gain far more by choosing a language that’s efficient to write in. (Beside that, Python has made huge performance gains since its inception anyway.)
Consider that in testing a real product, you will almost never be waiting on the test code to execute. You’re waiting for state transitions or responses from your products. Losing a few milliseconds in there when the tests are running overnight is trivial. Losing a few engineering-hours when a tester is struggling to implement a tricky test however has a cost, and your budget or your manager will notice that for sure.
3. Python is Growing
When choosing technology for a product, you may not want to consider how it benefits your employees’ resumes. But I promise you that they will, and the best way to get and retain high-quality talent is to keep them happy with their career progression. Check out the numbers for new jobs from indeed.com here. The old ways of building proprietary languages to lock your employees in are dying. The companies that succeed today are learning that they win when their employees win. Give them a project that directly improves their skills in real and marketable ways, and your employees will thank you by being excited to work on the project and stick around to see what other cool stuff they will get to do for you next.
4. Python Builds Amazing APIs With Ease
So far we’ve focused on business reasons for choosing Python for your test automation project. Now it’s time to explore what the language offers in technical options for robust and flexible test automation frameworks. This item actually deserves a few posts on its own. So check out the continuation here.