As someone who aced the recent job interview by solving the interview question in a 1 hour session with C#, you might think I prefer C++ or C# for creating tests. But I’m still very much a fan of the removal of time wasted compiling and time spent searching for a missing } curly brace. Sure, compiled code has it’s bonus moments in that it catches typos or wrong library versions before they even get in. As someone with an embedded and industrial background natively running code has always been my bag, but as I get older I find my hand forced. I cannot really keep swapping between 3 languages on a daily or even weekly basis. I end up forgetting to add ; semicolons and at other times I end up having them where they are not needed at all for example. Performance and stress testing is one balance to the entire act too. But on the other hand a simple to read script-centric targeted language often scales a lot faster when I ned to bang out a batch of tests.
What is your favourite language to automate in and why. I’ve deliberately been vague here, because I want open replies.
I believe, this depend upon which language you started writing and learning to code first?! If I talk about my experience over a decade ago, I started using Selenium WebDriver with Java and I call Java my first love in test automation, its not that I cant write code in C sharp, JavaScript, TypeScript, Ruby, however I will prefer Java over anything else as it has become my comfort language.
I believe my comfort level also derived from Java’s stronger community over internet back then as well.
Similar to @aimantirmizi my comfort zone is definitely Java, but I’ve been working with C# for a couple of months and I’m enjoying it so far. There are enough similarities between the two for it to feel familiar.
I prefer statically/strongly typed languages - you’re forced to put a little more thought into how you want to set things up. I think this helps in the long run if you’re building a relatively complex automation framework.
I prefer C#. I like the possibilities this language offers. But when it comes to automation testing, I don’t focus only on the language itself. Since I work with games, the programming language is usually chosen based on the engine. Because I prefer Unity, I also prefer C#.
I’ve tried Python and Java, but for me, they’re a bit of a headache. I’ve also used C++ and Blueprints in Unreal Engine, but that’s too much for me.
Are you asking intentionally just for automation? Or also any development in/for testing?
My preferred language for both is Groovy. I do anything from little scripts up to full blown tools with thousand(s of) lines.
Reasons:
Static typing is optional. Some code is easier to do with dynamic typing. And sometimes I don’t care for typing so that I develop faster.
It’s low on boiler plate code, which I constantly forget and have to look up in other languages (Damn you, Stream.open and .close). Especial reading and writing files are just getter and setter of the text property.
You can use every Java library.
Which also helps to get support from my Java developers.
You can easily create programmatically HTML with it for e.g. custom reports.
You search through XMLs files easily
Many more stuff which is way more demanding in other programming languages.
You don’t need a semicolon at line endings.
If I have a choice I use Groovy. Specifically at automation I have less complex code than on my other tools and do it in other languages. Currently Typescript with Cypress so that also my developers can write and maintain cases.
I personally prefer ruby if/when I can for its more English like syntax, python comes next for its simplicity though it has its syntax quirks.
If I need something compile time as well or more like traditional programming, I’d consider go/golang, offering features of scripting languages and compiled languages.
From the test perspective beyond unit testing, it can depend on what test/automation library support is available to the languages as well.