What language should I choose for my automation

Satyajit Malugu
mobile-testing
Published in
3 min readFeb 10, 2015

First, congrats on being in such a fortuitous situation. This is what some would call a happy problem to have. In many companies drones of SDET’s lack this choice and just have to follow what their company has mandated. You got a chance to make a choice based on current situation and perhaps your individuality. I am lucky to have face this choice in all my three previous jobs.

Assumption

In today’s technology world it is truly difficult to stay mono-lingual given the proliferation of usurpers like JavaScript, Python, Ruby etc in addition to mainstream languages like Java, C#. Hence I am assuming you are comfortable or interested in considering other language choices.

3 questions

  1. Do you have a lot of legacy automation code that you have to maintain — then unless you are doing a brand new project, you are stuck with whatever is the existing language.
  2. Are devs expected to write/maintain automation code? Does automation code has to be in the same language as dev code? Before you say yes consider the ratio of devs:test, if its more than 3:1 then forget whatever you are told in your job interview, devs will not bother with your code. You are alone and that’s not a bad thing.
  3. Do you have to only work on windows machines? Then your choices are limited. Though you can make a PC work for OS languages, its not as clean as a mac/linux box.
If you have answered no to all 3 then my recommendation is to go for RUBY. Why? Glad you asked

Why Ruby

  1. It is a language for humans. A well written Ruby code can be read by a non-programmer and can understand its flow without getting diverted with language mumbo-jumbo.
  2. Plethora of third party libraries — RubyGems and easy to get them to your project. Just add a line in Gemfile and run bundle and you got it.
  3. Code is concise. Unless you are measured/paid by lines of code written, less code == better code.
  4. Meta-programming support in Ruby is a first class citizen. With automation there are many opportunities to make your concise with meta programming constructs. My favorite example is a smart page object — good topic for a future post.
  5. Ruby also have good bindings support for appium if you have to do native device automation.

Now Python has the exact same set of factors going for it, so its equivalent to choosing Ruby.

Why I don’t think C#/Java are good choices

  1. They are not high level you still mostly have to create objects, initialize them etc. These are still not language for human.
  2. Feature heavy languages- for getting basic automation we don’t need all the properties, setters, getters, inheritance, interfaces, references etc.
  3. Both of them needs a build phase. For automation I don’t think this time add gives any value. Just write the code and run it.
  4. Not easy to include and debug third party libraries. You can’t always get code of these libraries and even if they are OS, you can’t debug inside the library.

Factors against Ruby

Now I won’t be a good tester if I can’t critique my argument. There are some problems with Ruby as well

  1. It doesn’t come with a standardized testing mechanism like JUnit or Nunit. They are many competing alternatives like RSpec, Minitest, Cucumber etc.
  2. Its not straightforward to debug in Ruby. Ruby’s debugger is its curse. Its not as bad as printf statements of Swyft but pry is not as easy as C#/Java debug. Rubymine makes it easy though.
  3. There is no standard selenium wrapper like in C# or Java. There is a standard selenium- webdriver but on top of it there is capybara and cucumber. Again you have to make some choices.
  4. Also unlike RoR which enjoys a rigid directory and config structure your custom Ruby test framework has to decide a lot of things — how to require one file/function in another, where to place page objects vs tests vs business logic, how to write rake files etc.

In conclusion, I would recommend Ruby or a similar higher level language in spite of having some small troubles, you will be happy in the long run.

--

--