Ranorex Logo

You Don’t Need Cucumber for BDD

|
you-don't-need-cucumber-for-BDD-blog-image

What BDD is really about

Behavior-Driven Development (BDD) is a collaborative approach where developers, testers, and business stakeholders work together to define how software should behave before anyone writes code. Cucumber popularized BDD by letting teams write tests in plain English using Gherkin syntax.

But here’s the thing: BDD isn’t a tool or framework. It’s a methodology. Many teams now automatically assume BDD means adopting Cucumber, but you can apply BDD principles just as effectively with well-structured code, clear naming, and readable logs.

The core principles

BDD comes down to a few key ideas:

  • Collaborating with both technical and non-technical people
  • Agreeing on system behavior before implementation
  • Writing tests that read like real-world scenarios
  • Using the GIVEN–WHEN–THEN structure

The goal is making sure everyone’s on the same page about what’s being built.

Why Cucumber often misses the mark

When Cucumber first appeared, it seemed like a breakthrough. Tests written in plain English that non-technical stakeholders could contribute to, with engineers just wiring up the implementation.

In practice, that rarely happens. In every organization I’ve worked with, engineers ended up writing and maintaining complex regex files to keep tests running. Business stakeholders didn’t engage with the Gherkin files, and the extra abstraction layer added maintenance burden without delivering real value.

I’ve been asked to migrate Cucumber test suites back to plain code multiple times. The lesson is clear: You don’t need Gherkin to do BDD well. Clear naming, thoughtful structure, and good logging achieve the same clarity with less complexity.

BDD implementation examples

BDD in Selenium (Java)

Here’s how to write a Selenium test with GIVEN–WHEN–THEN built directly into your code:

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.logging.Logger;

public class LoginTest {
    private WebDriver driver;
    private static final Logger logger = Logger.getLogger(LoginTest.class.getName());

    @Before
    public void setUp() {
        driver = new ChromeDriver();
    }

    @After
    public void tearDown() {
        driver.quit();
    }

    @Test
    public void userCanLoginSuccessfully() {
        /*
         Scenario: User can log in with valid credentials
           GIVEN the user is on the login page
           WHEN they enter valid credentials
           THEN they should be redirected to the dashboard
        */

        givenUserIsOnLoginPage();
        whenUserLogsInWithValidCredentials();
        thenUserShouldSeeDashboard();
    }

    private void givenUserIsOnLoginPage() {
        logger.info("GIVEN the user is on the login page");
        driver.get("https://example.com/login");
    }

    private void whenUserLogsInWithValidCredentials() {
        logger.info("WHEN the user enters valid credentials and submits the form");
        driver.findElement(By.id("username")).sendKeys("testuser");
        driver.findElement(By.id("password")).sendKeys("password123");
        driver.findElement(By.id("login-button")).click();
    }

    private void thenUserShouldSeeDashboard() {
        logger.info("THEN the user should see the dashboard");
        assert driver.getTitle().contains("Dashboard");
    }
}

The test reads like a scenario and produces logs that match the behavior. No regex mapping. No parsing layers. Just clear, straightforward steps.

BDD in Ranorex

Ranorex supports BDD through smart use of recordings, repository items, and custom code.

Recording-Based Approach

Insert Report → Info messages at key points and use descriptive naming for modules and repository items:

Modules:

  • Given_User_Is_On_Login_Page
  • When_User_Logs_In_With_Valid_Credentials
  • Then_User_Should_See_Dashboard

Repository Items:

  • UsernameField
  • PasswordField
  • LoginButton
  • DashboardHeader

Execution Log:

GIVEN: User is on the login page
  -> Open browser at https://example.com/login
WHEN: User enters valid credentials
  -> Set value 'testuser' in UsernameField
  -> Set value 'password123' in PasswordField
  -> Click LoginButton
THEN: User should see the dashboard
  -> Validate exists: DashboardHeader

Readable logs with no code changes needed.

Recording + Custom Code

For larger projects, move logic into reusable methods:

using Ranorex;

public static class UserCode
{
    public static void NavigateToLoginPage()
    {
        Report.Info("GIVEN: User navigates to the login page");
        Host.Local.OpenBrowser("https://example.com/login", "chrome", "", false, false, false, false, false);
    }

    public static void Login(string username, string password)
    {
        Report.Info("WHEN: User enters valid credentials and submits the form");
        var repo = ExampleRepository.Instance;
        repo.UsernameField.Element.SetAttributeValue("value", username);
        repo.PasswordField.Element.SetAttributeValue("value", password);
        repo.LoginButton.Click();
    }

    public static void VerifyDashboardVisible()
    {
        Report.Info("THEN: User should see the dashboard");
        Validate.Exists(ExampleRepository.Instance.DashboardHeaderInfo);
    }
}

Your recording modules simply call these methods, keeping logs clean and scenarios readable.

Practical tips

  • Write scenarios in plain language first, then translate them into code or recordings
  • Use business terminology in your naming, not just technical jargon
  • Leverage logging to reflect GIVEN–WHEN–THEN structure in test output
  • Focus on behavior—what users do—rather than just implementation details

Bottom line

Effective BDD doesn’t require Cucumber. Clear naming, structured code, and meaningful logs deliver the same benefits with less complexity. This approach reduces maintenance overhead and keeps your focus where it belongs: on verifying that system behavior matches stakeholder expectations.


About the author

Devon Jones is a Solutions Architect at Ranorex, where she collaborates across Product, Marketing, Partnership, and other departments to enhance and expand Ranorex as both a product and brand. With over 10 years of automation engineering experience, including two years as Lead QA, she brings deep technical expertise and quality assurance knowledge to her current role. Before transitioning to tech, Devon spent a decade as a social worker and case manager supporting adults with disabilities. This unique background, combining technical leadership, quality expertise, and human-centered problem-solving, enables her to bridge the gap between complex technical solutions and real-world user needs in the test automation space

In This Article

Sign up for our newsletter

Share this article

Related Articles

A-Guide-to-Automated-Test-Execution-with-Ranorex-blog-image

A Guide to Automated Test Execution with Ranorex

February 12, 2026
Learn how Ranorex Studio enables fast, accurate, and intuitive automated testing for software applications. What is Automated Test Execution? Automated test execution refers to any methodology for running tests on software applications without human intervention. Before automated...
Automated-Regression-Testing-Tools-Which-One-Actually-Works-for-Your-Team-blog-image

Automated Regression Testing Tools: Which One Actually Works for Your Team?

December 16, 2025
The best automated regression testing tools are:  Your regression suite passed 100% on Friday.  Monday morning, three tests fail with no code changes. Sound familiar? Most QA teams know automated regression testing saves time—in theory. In practice, you’re debuggi...
How-to-measure-assess-and-improve-test-coverage-blog-image

How to Measure, Assess, and Improve Test Coverage

December 11, 2025
Test coverage is an important metric to track for your testing program, revealing how thoroughly your test suite validates your application code. Understanding this concept will greatly benefit QA leaders who are managing complex software development products. By learning how to ...