01 logo

Why Ruby is the Best Scripting Language for End-to-End Test Automation?

Ruby is an excellent all-around scripting language that was used to pioneer web test automation and is a “most-in-demand” skill.

By Zhimin ZhanPublished 6 months ago 4 min read
Like

This is an abridged version of my Medium article (2023-07-23).

As a veteran software engineer and test automation engineer/SDET, I fully understand how sensitive when software engineers come to language debate. If you are an engineer fixated on a specific language, don’t read this.

1. My Objectiveness to Programming Languages

If a software engineer only knows one programming language well, of course, his/her opinion on language choices is biased. I am probably more objective than most, as My Selenium Recipes Book series covers all of Selenium WebDriver’s 5 official programming languages.

I have written thousands of end-to-end tests in all these 5 languages, most in Ruby.

2. Ruby pioneered web test automation

Web Test Automation started with Watir (Web Application Testing in Ruby), which drives Internet Explorer with its OLE, in ~2003. The creators loved Ruby so much that they included the language in the framework name. (Ruby on Rails, a popular web framework, did the same).

RSpec (Ruby), to my knowledge, is the first BDD framework. Mocha (JavaScript) and PyTest (Python) are clones of RSpec.

Cucumber, the first Gherkin-style BDD framework, was also developed in Ruby. SpecFlow (C#) and JBehave (Java) are the clones of Cucumber (Ruby).

3. Ruby is designed with features that are good for test automation

Compiled languages such as Java and C# are designed for building business apps, not for testing. Automated Test Scripts Shall be in the Syntax of a Scripting Language, Naturally!

Scripting languages, on the other hand, are designed to execute automation tasks (typically, utility, build automation or test automation). In the words, design with automated testing in mind.

JavaScript is a scripting language used to develop web pages. In other words, it is developer-focused. The main reason that there are so many (failed) JavaScript automation frameworks: developers try to use the coding language for testing.

For more, check out my other article, Why JavaScript Is Not a Suitable Language for Real Web Test Automation?

Python is a good scripting language, which became popular because of AI/Machine Learning. For testing, its indentation rule is no good.

4. Ruby is “elegant, expressive, and tersely powerful” and “ideal”

Authors of “Agile Testing”, a classic testing book, used the above adjectives to describe Ruby.

5. A good Software Engineer should learn Ruby

Test Automation is a skill not taught at Universities, i.e., need to learn it.

Many automated testers came from programming backgrounds, they tend to use a coder’s thinking and mindset to script end-to-end tests. Of course, this often leads to failures.

6. “Ruby is the most in-demand skill”

According to Hired’s 2023 State of Software Engineers Report, “Ruby on Rails and Ruby are the top two most in-demand skills”

7. Ruby is easy to learn

My daughter learned programming in Ruby at the age of 12, using this book (from the very beginning).

I have trained many manual testers and business analysts on test automation. They all find the syntax (Ruby) easy and intuitive. Below are messages from a manual tester after the 1.5 hours of hands-on training.

8. Ruby, on daily testing use, is faster than Java and C#

Scripting languages are much slower than compiled languages by nature. But don’t forget the context: end-to-end testing. The majority of execution time is on the app itself. For example, if a payment step takes 10 seconds and an execution time of 10.5 in Ruby and 10.02 in Java, makes little difference. (check out Performance Comparison: Selenium Ruby, Python, and JavaScript)

My daughter did a benchmark comparing Selenium Ruby and C# for the same test case. C#: 11.8 seconds, Ruby: 8.5 seconds ✅.

9. Ruby is delightful to use!

Finally, after the above facts and experts’ (four co-authors of Agile Manifesto) opinions. Here is my added opinion: “Ruby is delightful to use!”, this is after I have professionally (getting paid) used the following languages: C, Java, Perl, C#, C++, JavaScript, Perl and Ruby, over the last 27 years.

“Ruby is a wonderfully powerful and useful language” — Martin Fowler

“programming in any language other than ruby will feel like you’re pushing rope.” — Mike Clark, author of “Pragmatic Project Automation”

“Ruby is smart, elegant, and fun” — James Britt

“Ruby is one of those great languages that takes an afternoon to start using, and years (maybe a lifetime) to master. In C, I’m always having to work around the limitations of the language; in Ruby, I’m always discovering a neater, cleaner, more efficient way to do things. ” –Ben Giddings

in the famous “Programming Ruby” book by Dave Thomas, Chad Fowler and Andy Hunt (two of them are coauthors of Agile Manifesto”

I still remember, after using Ruby for a month in my spare time, one day when I was coding (at that time, I was a Java tech lead, contractor), I surprisingly realized that I was thinking of Ruby first, then converted to Java! I have programmed Java and JavaScript for about 10 years! The “thinking in Ruby” became more and more obvious, and soon I realized that I couldn’t do much Java/JavaScript work for long. Maybe a year later, I switched my day work from Programming to Automated Testing, using Ruby at work. Never looked back. I still love programming, but do it at home for developing my own apps, most of them in Ruby, too.

----

For more reasons and Ruby test examples, check out the original article on Medium.

startup
Like

About the Creator

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer.

A top writer on Test Automation, with 150+ articles featured in leading software testing newsletters.

My Most Viewed Articles on Vocal.

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.