The first step is simply getting Boomerang! installed. You can find instructions for that here.
To verify your installation try running boomerang --version
from the command line. If everything checks out you should get back along the lines of Boomerang! {version} by Jesse G. Donat
.
Coming Soon!
The boomerang
executable optionally takes a filename or directory as the final argument.
When loading a directory it will recursively search for files matching the glob *Spec.php
and load them as tests.
As an example, testing a simple API with the following structure
├── users.json
└── buildings.json
One could simply structure the API test folder
├── usersSpec.php
└── buildingsSpec.php
There are three steps to creating a test.
The following is a simple example that ensures a call returns the HTTP status code 200
.
<?php
namespace Boomerang;
$req = new HttpRequest('http://httpbin.org/get'); // Create the API Request
$response = $req->makeRequest(); // Execute the request, return a Response object
$valid = new HttpResponseValidator($response); // Create a basic response validator.
$valid->expectStatus(200) // State a HTTP 200 status expectation
->expectHeaderContains('Content-Type', 'json'); // State a Content-Type expectation
Boomerang::addValidator($valid); // Register the validator with Boomerang to output the results