Automation Testing

3 Ways Your UI-Based Cucumber BDD Can Go Bad

By Test Guild
  • Share:
Join the Guild for FREE

I recently interviewed the creator of Cucumber, Aslak Hellesøy, about the ten year anniversary of BDD with Cucumber as well as BDD testing.

During our talk, he gave me one of the best summaries of why using just UI-based BDD testing is a bad idea.

Three Reasons Why UI-Based BDD Testing Can Stink

Aslak outlined three ways in which UI-based BDD using tools like Selenium can cause issues. They are due to UI tests, in general, being:

  • Slow
  • Brittle
  • Hard To Maintain

The Most Common BDD Mistake

One of the most common mistakes Aslak and myself see is when people write Cucumber scenarios in the same way that one would write a manual test script.

A manual test very often involves opening up a web page, navigating to a certain page, filling in some fields, and either clicking some buttons or looking at the screen to see what's there.

All these things can be done with Cucumber combined with a tool like Selenium.

Why this BDD Approach is Bad

But it just so happens that if that's what you are doing, you are writing the slowest possible tests possible. They're also the most brittle tests you can possibly write, as well as the most difficult to diagnose.

Why UI-Based BDD is Slow

UI-based BDD tests are slow because they go through all of the layers of your stack with lots of networking.

Why UI-Based BDD is Brittle

UI-based BDD testing tends to be brittle because your user interface keeps changing; it’s typically the part of the application that changes more often than the actual logic underneath.

Why UI-Based BDD is Hard to Debug

Lastly, UI-based BDDs are hard to diagnose when they fail because the problem could literally be anywhere in your system if you don't get a good stack trace when something doesn't work properly.

A Better BDD Testing Approach for Faster Tests

The conventional wisdom to address this problem is to try and write your scenarios in such a way that you don’t talk about the user interface.

Instead, you talk about what the user intends to do.

For example, imagine that want to transfer some money from your checking account to your savings account.

One way to write that scenario is to say that I open up my bank’s website, click on my checking account, enter the amount to be transferred into the box and submit the update account button, which means the balance label should be this value.

But you can write this in a much more terse way.

For example, if I have a hundred dollars in my checking account and a hundred dollars in my savings account, when I transfer $20 from the checking to savings I should then have $80 in checking and $120 in savings.

So you're talking more in terms of all of the business processes rather than just the user interface.

Writing BDD Test for Business Logic is not UI-Specific

This approach has some great benefits. Now that you're not tied to the user interface, you can choose which stack level of your application you want to connect your test to.

You can still connect to the UI if you wish, but you can also– with a little bit of programming–connect them to the lower- level domain logic that sits behind the UI and even behind the web server and test the same logic for exceptionally fast feedback.

Writing BDD for Readability by All Team Members

Another benefit you get from this is that you’ll know you're documenting the business process instead of documenting the UI, so you're much more likely to be able to show a Cucumber scenario to somebody from the business and get some valuable feedback on it.

That's actually been a problem for many teams; they have reams and reams of Given, When, Then and it's so detailed that when you give it to somebody who just wants to make sure you're doing the right thing, they can't follow it and don't particularly want to see it.

How to Make Really Fast Cucumber Scenarios

By now might be saying to yourself, “This makes sense, but give me an actionable way that can actually help me make my Cucumber scenarios faster.”

No worries.

If you Google todo-subsecond you’ll find a small To-Do list application that uses Cucumber as well as some design patterns that will help for make your end-to-end tests run in milliseconds.

This example uses a tiny web app to demonstrate sub-second full-stack acceptance tests with Node.js and Cucumber, but the principles apply to any programming language you might be using for your Cucumber BDD projects.

Breaking down this example is a great way to learn about more efficient Cucumber BDD design patterns for your tests.

To discover other ways to help improve your test automation efforts make sure to check out the Automation Guild Conference and Community!

You can still get the recordings for 2017 Automation Guild conference that had sessions from Seb Rose on An introduction to Cucumber and Matt Wynne on Keeping your Cucumbers sweet.

A bearded man with blue glasses and a black-and-white jacket smiles at a microphone in a studio setting.

About Joe Colantonio

Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.

Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.

With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.

He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.

Follow him on LinkedIn or check out more at TestGuild.com.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

30 AI Terms Every Tester Should Know

Posted on 04/24/2025

Why This AI/ML List Matters to You (and Your Testing Career) AI and ...

5 Top Model Context Protocol Automation Tools (MCP Guide 2025)

Posted on 04/09/2025

What is Model Context Protocol (MCP) Model Context Protocol (MCP) is an open ...

What is TDD (Test Driven Development)

Posted on 04/05/2025

What is Test-Driven Development (TDD)? Test-Driven Development is a software development approach that ...