These three come up together because they all help you write automated tests, but they take very different routes to get there. pytest is code-first. Cucumber is behaviour-driven. Robot Framework is keyword-driven. Knowing what those words mean in practice is the whole decision.
The three approaches in one paragraph each
pytest is a Python testing framework. You write tests as Python functions, use plain assertions, and lean on a large plugin ecosystem. It is flexible, and it is a common choice for unit and integration tests where you want direct control in code.
Cucumber is a behaviour-driven development tool. You describe behaviour in Gherkin, a "Given, When, Then" format that reads like English, and then you write step definitions in code that make each line executable. The readable feature files are the selling point, and the glue behind them is code you maintain.
Robot Framework is keyword-driven. You write tests as sequences of named keywords in a readable, tabular syntax, and you build your own higher-level keywords from lower-level ones. It is readable like Cucumber, but you do not have to write and maintain a separate layer of step definitions to make it run.
The same idea, three ways
A login check in pytest:
def test_valid_login(client):
response = client.post("/login", data={"user": "standard_user", "pw": "secret"})
assert "Welcome" in response.text
In Cucumber, a feature file plus the step definitions behind it:
Feature: Login
Scenario: A registered user can log in
Given I am on the login page
When I log in as "standard_user"
Then I should see "Welcome"
@given("I am on the login page")
def step_open_login(context):
context.page.goto("https://demo.example.com/login")
# ...and a step definition for every other line
In Robot Framework:
*** Test Cases ***
A Registered User Can Log In
Open The Login Page
Log In As standard_user
Page Should Show Welcome
Notice what Robot Framework does not need. The readable steps are the test, and Log In As is just a user keyword you define once. There is no separate mapping file to keep in sync.
How they compare
| pytest | Cucumber | Robot Framework | |
|---|---|---|---|
| Style | Code-first | Behaviour-driven (Gherkin) | Keyword-driven |
| You write in | Python | Gherkin plus step definitions in code | Readable keyword syntax |
| Readable by non-coders | No | Yes, for the feature files | Yes, for the whole test |
| Extra glue to maintain | None, it is all code | Yes, step definitions | No separate step layer |
| Best level | Unit and integration | Acceptance, with business input | System, acceptance, end-to-end |
| Reporting | Via plugins | Via plugins | Built in |
When to choose which
Choose pytest when your tests are close to the code, you are testing units or integration points, and your team is comfortable in Python. It gives you the most direct control and the least ceremony for developer-facing tests.
Choose Cucumber when the readable "Given, When, Then" format is important to your stakeholders and you accept the cost of maintaining step definitions to get it. It works well when business people co-author the scenarios.
Choose Robot Framework when you want readable, business-legible tests without a separate glue layer, and when your testing spans the web, APIs and other systems. You get the readability that draws people to Cucumber, the built-in structure and reporting, and one syntax across technologies. If you like the behaviour-driven wording, Robot Framework supports a "Given, When, Then" style too, so you can have that phrasing without giving up the keyword model.
In short
They are not really rivals for the same job. pytest owns the low level. Cucumber and Robot Framework both aim for readable, higher-level tests, and between those two, Robot Framework gets you there with less to maintain and more reach beyond the browser.
If Robot Framework is the fit, our Robot Framework Certified Professional course takes you from the syntax to real web and API suites and prepares you for the RFCP exam.
Frequently asked questions
Can Robot Framework do behaviour-driven testing? Yes. It supports "Given, When, Then" wording as keywords, so you can write behaviour-driven style tests without maintaining separate step definitions.
Is pytest better than Robot Framework? For unit and integration tests in Python, pytest is usually the better fit. For readable system and acceptance tests across technologies, Robot Framework tends to win. Many teams use both.
Why choose Robot Framework over Cucumber? Both give readable tests. Robot Framework does not require a separate step-definition layer to make them run, which is less code to maintain.
Keep reading: keyword-driven testing explained for the model behind Robot Framework, or What is Robot Framework? for the basics.