Why do we teach Automation in Python, not Java

May 3, 2020

Author: Svetlana Levinson, 7 years of experience in all types of automation and manual testing in Python, Java and Ruby in Silicon Valley. Co-author and teacher of the Manual / API Testing and Test Automation with Python courses.

Here at QA School JobEasy.co we often hear disputes over which programming language is worth learning to get to work faster in Test Automation – Java or Python? This is a long-standing dispute which will hardly be resolved in the near future. Our teachers are fluent in both Java and Python, so we could teach both of these languages, but we chose Python for our students to be learnt and decided not to teach Java at all. Read on to understand why.

Just want to let Java fans know that in our analysis the evaluation criteria were determined by the main goal of our course:

To give the necessary quality minimum for automation so that students can get a salary of $ 115,000 per year for 2-4 months from the beginning of the course.

Just want to let Java fans know that in our analysis the evaluation criteria were determined by the main goal of our course:

# 1 Easy to learn

In order to teach you how to automate web testing well, you need to understand the vocabulary of the programming language, how to work with Selenium, learn to read HTML and CSS to find locators, get familiar with Git, the basics of CI and reports generation.

This is too much and difficult for people who often do not have any programming experience. At the same time, we do not want a person to memorize definitions, cramming constructions and solutions to algorithms for the interview. We want students to understand exactly what they do.

So, one of the key criteria for choosing a language is learning simplicity. Python is easier and faster to learn for a beginner as the first programming language, and most importantly, to figure it out, and not just learn some constructions by heart. Just google “easiest programming language to learn” and make sure that Python is the top line. For example, in this survey of nearly a thousand programmers, HTML came first, Python came second, and JavaScript came third with a significant lag behind Python.

The article of an authoritative blog Automation Panda says that Python suits best for test automation – everything is simpler, clearer, easier to maintain, there are lots of libraries with ready-made solutions, and the Pytest Framework is generally perfect and quickly mastered.

Pytest is one of the best frameworks for testing among all possible frameworks in all programming languages. It handles any functional tests: unit, integration and end-to-end. Test cases are written just like functions, i.e. without side effects, since global variables are excluded, and can accept parameterized inputs.

Fixtures is a versatile, frequently used way for setup and cleanup functions. The main “assert” operators have an automatic introspection system, so error messages are always clear. Tests can be sorted during the execution,. Plugins extend Pytest ability to cover code, run tests simultaneously, use Gherkin scripts, and integrate with other frameworks such as Django and Flask. Other Python test frameworks are cool too, but Pytest is definitely the best.

# 2 Applied value

Although Python is great for beginners, it's not a toy, it's one of the most popular programming languages ​​in the world. It is always in the top of TIOBE, Stack Overflow and GitHub (also GitHut), as this is the favorite choice of lots of experts. The Python community is also pushing it forward.

Python development is easy to scale thanks to well-designed syntax, good structure, modularity, and a various ecosystem of tools and packages. A variety of command line methods allows you to fit into any tool or workflow. The fact that the code written in Python can run slower than a code in some other languages ​​is not a problem for functional tests, since system delays (response time for a Web page or REST calls) are much slower than optimal productivity in terms of a language.

# 3 Jobs number

The next key point is the demand for a specialist in the market, i.e. the number of vacancies. According to Indeed.com (all the figures are actual at the time of writing):

Let’s check that on one more popular job search site: Dice.com:

At first sight, there are slightly more Java vacancies, but if you specify the criteria Python AND Automation and Java AND Automation in the search, we get:

# 4 Competition for a vacancy

It is important to understand not only the number of vacancies, but also the number of potential competitor candidates for each place. We see approximately the same number of vacancies in Java and Python, however, there are usually more job applicants in Automation in Java! 

Below there is the number of resumes posted by job applicants on one of the most popular job search sites Indeed.com (for the last 3 months, all the figures are actual at the time of writing):

There are hundreds of job seekers in the market, for example, from sunny India, where all, as one, know Java well, or just say so. In our opinion, it is easier to find a job and get good money with Python, since the number of vacancies is almost the same in both Python and Java, but there are fewer competitors in Python.

# 5 Understanding Code

There is an opinion that it is necessary not only to automate tests, but also to understand the developers’ code. Is it? The code can be neither in Java nor in Python at all. Imagine the situation, you spent an extra year and learnt Java to “understand the development code”, started working, and the company’s back-end is written in Scala, and the front-end is in JavaScript / React. And you won’t understand most of the things, knowing only the language – you need to know the frameworks. In 99% of cases the tester should neither check, nor even see the developers’ code.

Such tests as integration, end-to-end, system, acceptance, regression, performance usually refer to high-level functional tests and often suit best from the black box perspective, so they do not have to be written in the same language as the tested product.

# 6 From Test Automation to Software Development

People say that if you learn Java, then it’s easier to become a developer. But Java for QA and for development are two different levels of the language with their own characteristics. This also applies to Python: initially it is simple, difficulties can arise only when going deeper, but the language is well structured. First of all, you need to understand the algorithms, OOP and practice. After you learn Python and get a job, you can learn Java or something else that will be interesting or necessary for a specific project. The salaries in Test Automation and Software Development, on average, are almost the same, therefore, perhaps this point will generally be irrelevant for most readers.

However, in terms of analyzing programming languages ​​according to different criteria, pay attention to this matrix and its description from the Automation Panda blog:

Conclusion

We think that Python is the best language for Test Automation according to the criteria above.

Java is also a good choice, and the arguments in favor of Java should also be considered, here you can not settle the dispute between fans of Python and Java. However, as teachers, we obviously advise beginners to learn automation in Python, since this way is more likely to be successful for the most, especially because of the Python simplicity learning.

We do not claim that the way to learn Java as the first programming language is wrong, just from our point of view, a school one’s, it is longer, more complicated and easier to get confused with Java. Automation is taught everywhere in different ways too, we often see that students are overloaded with optional knowledge, which is better to master after getting a job, which in our opinion will definitely cause a mess in the head.

Our goal as a school teaching automation is to speed up a one’s salary of more than $ 115,000 a year and maximize the chances of getting a job within 2–4 months from the beginning of the course.