https://github.com/ubirak/rest-api-behat-extension
Stuff to easily test your rest api with Behat
https://github.com/ubirak/rest-api-behat-extension
behat rest-api test-automation
Last synced: 12 days ago
JSON representation
Stuff to easily test your rest api with Behat
- Host: GitHub
- URL: https://github.com/ubirak/rest-api-behat-extension
- Owner: ubirak
- License: mit
- Created: 2015-02-12T10:24:28.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-27T08:58:04.000Z (5 months ago)
- Last Synced: 2025-04-12T23:34:16.075Z (12 days ago)
- Topics: behat, rest-api, test-automation
- Language: PHP
- Homepage:
- Size: 176 KB
- Stars: 39
- Watchers: 9
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RestApiExtension for Behat
* [Branch behat2](https://github.com/ubirak/rest-api-behat-extension/tree/behat-2.x) : **Behat 2.x**
* [Branch master](https://github.com/ubirak/rest-api-behat-extension/tree/master) : **Behat 3.x**[](https://travis-ci.org/ubirak/rest-api-behat-extension)
[](https://scrutinizer-ci.com/g/ubirak/rest-api-behat-extension/?branch=master)
For now only JSON api is supported to analyze response, but you could use REST part to perform request on any type of api.
## Warning
From version `7.0`, namespace vendor changed from `Rezzza` to `Ubirak`.
## Install
Require the package as a development dependency :
```sh
composer require --dev ubirak/rest-api-behat-extension
```Don't forget to load the extension and the context if needed in your `behat.yml` :
```yaml
default:
extensions:
Ubirak\RestApiBehatExtension\Extension:
rest:
base_url: http://localhost:8888
store_response: true
suites:
default:
contexts:
- Ubirak\RestApiBehatExtension\RestApiContext
- Ubirak\RestApiBehatExtension\Json\JsonContext
```Then you will need to require in your composer the http client you want to use, and the message factory.
Example:
```
composer require --dev guzzlehttp/psr7 php-http/curl-client
```## Usage
You can use directly the `JsonContext` or `RestApiContext` by loading them in your behat.yml or use the `RestApiBrowser` and `JsonInspector` by adding them in the construct of your own context.```php
restApiBrowser = $restApiBrowser;
$this->jsonInspector = $jsonInspector;
}
}
```