DEV Community

Sabarish Sasidharan
Sabarish Sasidharan

Posted on

3 1

Should you use BDD for API testing?

BDD is a collaboration practice: you describe business rules, examples of these rules, and acceptance criteria that illustrate these rules. Some of these acceptance criteria can be potentially automated.

Detailed API testing (e.g. testing CRUD functionalities, error codes, JSON format etc.) is rarely of much interest to the business, so it generally makes little sense to use Gherkin to express them - it just adds an extra layer of complexity. Lower level tools such as RestAssured do the job just fine. And testing REST APIs with any JavaScript test library is pretty trivial. So if your team finds it more efficient to write REST API tests with a tool like Karate, that's great! But it ain't BDD, and it's not the only game in town.

The only exception is where you might use Cucumber as a communication tool between developers across teams, as a more expressive way to describe and document API contracts. But you can do this with contract testing tools as well, though it may not be as readable.

Let me know your thoughts in the comments!

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay