<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Phil Mander</title>
    <description>The latest articles on DEV Community by Phil Mander (@philmander).</description>
    <link>https://dev.to/philmander</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F28478%2F376b1883-e734-44b4-b2a7-0ca0bf2fe901.jpeg</url>
      <title>DEV Community: Phil Mander</title>
      <link>https://dev.to/philmander</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/philmander"/>
    <language>en</language>
    <item>
      <title>Introducing Bat: Behavioral API Tester</title>
      <dc:creator>Phil Mander</dc:creator>
      <pubDate>Wed, 28 Aug 2019 13:42:56 +0000</pubDate>
      <link>https://dev.to/philmander/introducing-bat-behavioral-api-tester-2d3a</link>
      <guid>https://dev.to/philmander/introducing-bat-behavioral-api-tester-2d3a</guid>
      <description>&lt;p&gt;I work at &lt;a href="https://careers.harver.com/" rel="noopener noreferrer"&gt;Harver&lt;/a&gt; where we have several mission critical, customer facing HTTP/Rest APIs built with Node.JS. When I joined, last year, the standard procedure to support developing and testing these APIs was to use Postman. But the process of integrating Postman with version control, writing Javascript tests with Postman's GUI and integrating into CI with Newman did not represent a particularly great developer experience to me. I wanted to find a way to improve upon this.&lt;/p&gt;

&lt;p&gt;I have always been a fan of &lt;a href="https://cucumber.io/" rel="noopener noreferrer"&gt;Cucumber&lt;/a&gt;, a tool for writing runnable software specifications in readable business language, and, in general, a Behavior Driven Development (BDD) approach to development. It occurred to me that Cucumber might be a great fit for developing and testing our HTTP APIs too.&lt;/p&gt;

&lt;p&gt;From here, together with my colleagues at Harver, we created &lt;a href="https://github.com/harver-engineering/bat" rel="noopener noreferrer"&gt;Bat (Behavioral API Tester)&lt;/a&gt;; a tool to help write runnable specifications for HTTP APIs, such as Rest, RPC and GraphQL, in readable English. Such specs can then be easily automated and integrated into your continuous integration pipeline. It runs on Node.JS and is based on &lt;a href="https://github.com/cucumber/cucumber-js" rel="noopener noreferrer"&gt;Cucumber.JS&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foru3cgodydgmv213ummt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foru3cgodydgmv213ummt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The full set of step definitions is &lt;a href="https://github.com/harver-engineering/bat/blob/master/docs/step-reference.md" rel="noopener noreferrer"&gt;documented here&lt;/a&gt;. We’ve also provided (and will continue to add) a bunch of &lt;a href="https://github.com/harver-engineering/bat/tree/master/examples" rel="noopener noreferrer"&gt;examples in the repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;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 (&lt;code&gt;Given&lt;/code&gt; steps), such as custom authentication procedures or setting up test data. Internally, it uses &lt;a href="https://visionmedia.github.io/superagent/" rel="noopener noreferrer"&gt;SuperAgent&lt;/a&gt; as an HTTP client and to maintain sessions.&lt;/p&gt;

&lt;p&gt;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 &lt;a href="https://github.com/harver-engineering/bat/blob/master/README.md" rel="noopener noreferrer"&gt;Readme&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;Now Bat is &lt;a href="https://github.com/harver-engineering/bat" rel="noopener noreferrer"&gt;open-source on Github&lt;/a&gt; and it is used by a broader audience, more missing features will become apparent. So please &lt;a href="https://github.com/harver-engineering/bat/issues" rel="noopener noreferrer"&gt;raise issues&lt;/a&gt; to request new features and raise bugs. If you want to contribute back to Bat, please check the &lt;a href="https://github.com/harver-engineering/bat/blob/master/CONTRIBUTING.md" rel="noopener noreferrer"&gt;Contributing Guide&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>api</category>
      <category>testing</category>
      <category>cucumber</category>
    </item>
  </channel>
</rss>
