Skip to content
QA Knowledge Hub

Cucumber vs Plain test code

Updated 2026-11-13 · 4 min read

Compare Cucumber scenarios with direct test code for shared examples, maintenance, reporting, debugging and team collaboration. Choose by the workflow, team skills and evidence you need.

Choose a tool by the tests you need to maintain and the evidence your team needs from failures. This page makes no speed, market-share or salary claims. The recommendations are practical judgments based on the capabilities described in the linked official documentation.

At a glance

ConsiderationCucumberPlain test code
Readable artifactGherkin feature/scenario files plus implementationNamed tests and helper code in the selected language
Business collaborationExamples can be discussed without reading implementation codeRequires readable tests or another shared example format
Execution mappingSteps are matched to step definitionsTests call implementation and helpers directly
Data examplesScenario Outline and Examples tablesRunner parameterization or ordinary data structures
ReuseStep definitions and lower-level helpersFunctions, fixtures and domain helpers
Maintenance riskAmbiguous wording, duplicate steps and hidden scenario stateOverabstracted helpers, unclear names and hidden fixture state
Debugging pathScenario, step match, step definition, helper and targetTest, helper and target
UI/API automationUses underlying libraries; not a browser driver itselfUses underlying libraries directly
BDD practiceTool supports examples but does not guarantee collaborationCollaborative discovery can happen without Cucumber

The same testing problem, side by side

Consider a coupon that should be rejected after expiry. In Cucumber, express the scenario in business terms: the coupon has expired, the customer applies it, the basket keeps its undiscounted amount and explains the rejection. A step definition then calls the API or UI library and asserts that outcome. Avoid turning every click into a separate sentence.

In direct test code, name the test “expired coupon leaves total unchanged,” create the same state, perform the same action and assert the same result. Domain helpers can keep setup readable without a text-to-code mapping layer. Neither approach supplies the expiry rule: the team still needs an agreed clock and boundary example.

Where Cucumber is the better choice

Choose Cucumber when product, development and testing colleagues actively discuss and maintain concrete examples together, and executable scenarios help preserve that agreement. Use a small domain vocabulary and keep UI mechanics in implementation code.

For a refund policy with several time boundaries and eligibility rules, an Examples table can become a useful discussion artifact. It loses value if only automation engineers read it or update it after the behavior is already built.

Where Plain test code is the better choice

Choose direct tests when the audience is primarily engineers and the extra feature-file and step-mapping layer does not improve shared understanding. Clear test names and domain helpers can express acceptance intent without Gherkin.

A low-level JSON serializer or parser usually benefits from focused code assertions rather than business prose for each internal branch. Keep customer-facing examples in the appropriate layer, and avoid reusing one enormous helper merely to reduce line count.

A useful pilot

Take one reproducible ShopLite defect and write the expected behavior in plain language first. Decide whether a feature file improves the conversation, then implement the smallest appropriate check. This page contains no executed Cucumber suite and makes no claim that an illustrative scenario was automated.

How to decide

  1. Ask who will read and change the examples before deciding to add a feature-file layer.
  2. Try one disputed business rule in a collaborative discussion and capture the agreed boundary cases.
  3. Implement a small example, then observe how another person diagnoses a deliberately failing assertion and adds a new case.
  4. Keep Cucumber if the shared language continues to earn its maintenance cost; keep collaborative BDD habits even if you use direct tests.

How to explain the choice in an interview

Describe your project’s constraints, the alternatives you considered and the evidence behind your choice. Separate features you checked in documentation from workflows you personally ran. A maintainable test that reveals a useful failure is a stronger example than a claim that one tool always wins.

Quick answers

Is BDD the same as writing Given/When/Then files?

No. Discovery and shared understanding are central; syntax alone does not create that collaboration.

Does Cucumber replace Selenium or an API client?

No. Step definitions use other libraries to drive the system and assert outcomes.

Sources

Want a project you can show in interviews?

The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.