Introducing Bat: Behavioral API Tester

Phil Mander
Aug 26, 2019 · 2 min read

At Harver we’re excited to announce that we’re open-sourcing our Cucumber based API testing tool, Bat (Behavioral API Tester).

Bat is a tool to help you write runnable specifications for HTTP APIs, such as REST, RPC and GraphQL. Such specs can then be easily automated and integrated into your continuous integration pipeline. Bat runs on Node.JS and is based on Cucumber.JS.

It works well for API testing with Cucumber because, within reason, there are a finite number of actions and assertions associated with testing an HTTP API. Bat builds upon Gherkin to create a common vocabulary (a DSL) for describing HTTP interactions. When taking a BDD approach to API development, such specifications provide a great way to write and review your intentions before writing any implementation code.

For example:

The full set of step definitions is documented here. We’ve also provided (and will continue to add) a bunch of examples in the repo.

Because Bat is essentially a plugin for Cucumber.JS, it’s easy to extend with custom step definitions. We most often do this at Harver for non-standard stuff related to setting up the context (Given steps), such as custom authentication procedures or setting up test data. Internally, it uses SuperAgent as an HTTP client and to maintain sessions.

Bat has more useful features for making it usable in the real world such as variable replacement, compatibility with Postman’s environment file format and integration points with Open API specifications. See the Readme for more details.

We’re delighted to share Bat as Harver’s first open source project. As it is used by a broader audience, more missing features will become apparent. So please raise issues on Github to request new features and raise bugs. If you want to contribute back to Bat, please check the Contributing Guide.

Harver Engineering

All things tech at Harver

Phil Mander

Written by

Head of Engineering at Harver

Harver Engineering

All things tech at Harver

More From Medium

Also tagged Cucumber

Top on Medium

Ed Yong
Mar 25 · 22 min read

27K

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade