2017-25 © Pedro Peláez
 

library restful-api-test-engine

This is a simple API Test-Engine. With simple JSON files you can run tests for all your RESTful API's.

image

s3cc0/restful-api-test-engine

This is a simple API Test-Engine. With simple JSON files you can run tests for all your RESTful API's.

  • Friday, December 11, 2015
  • by s3cc0
  • Repository
  • 3 Watchers
  • 5 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Introduction

This bundle provides a class for a simple API Test. The tests run on the terminal using run.php., (*1)

PHP API test engine screenshot, (*2)

How to use?

In the folder you will find run.php. Run this file with given params to setup the test engine., (*3)

If you have written some tests. Then you can execute them with:, (*4)

$ php run.php -u <api url> -t <test dir>  -m <mock dir> -n <number of rounds> -c <concurrency level>

Example:, (*5)

php run.php -u "http://httpbin.org" -t "jsons/"  -m "mocks/" -n 10 -c 2

How to write tests?

First of all, all tests must contain in the same folder, sub folder are ignored., (*6)

Create a simple test

A test can contain one or more subtests., (*7)

{
    "tests" : [
        {
            "name" : "Try to login with a wrong data",
            "path" : "/login",
            "method" : "POST",
            "request_params" : {
                "email" : "empty@me.com",
                "password" : "12345678"
            },
            "validation" : {
                "http_code" : 406,
                "response_params" : {
                    "code" : 406,
                    "message" : "$nn"
                }
            }
        },
        ...
    ]
}

Options, (*8)

  • $nn - means should be "not null"
  • $eq - means check variable 1 of a response is equal to variable 2
  • .$c - will return the count of the keypath (used for arrays)
  • $ia - means check variable is an array
  • more options in the next version ...

Save variables

To reuse output or created data you can save them to the globals (note: use unique keys!). Keypath should be a available path inside the request response., (*9)

"save_global" : [
    { "key" : "account_id", "keypath" : "account.id" }
]

To reuse the save variable you can do it easy with {$account_id}, (*10)

"name" : "Delete account with id {$account_id}",
"path" : "/accounts/{$account_id}",

Using mocks

If you have create mocks, you can easy load them by adding a string to the request_params. This example will load the mock account.json., (*11)

"request_params" : "account",

You can also use mocks to validate the response values. For this add mock inside the validation., (*12)

"validation" : {
    "http_code" : 200,
    "mock" : "account"
},

Extended Header

You can extend and overwrite the reuqest header using the header in the test set. The header variables will also listing to the global saved variables., (*13)

"header" : {
    "Authorization" : "Bearer {$access_token}" 
}

The Versions

11/12 2015

dev-master

9999999-dev

This is a simple API Test-Engine. With simple JSON files you can run tests for all your RESTful API's.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Kristof Friess

api test restful

11/12 2015

dev-master-dev

dev-master-dev

This is a simple API Test-Engine. With simple JSON files you can run tests for all your RESTful API's.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Kristof Friess

api test restful

11/12 2015

v1.0-stable

1.0.0.0

This is a simple API Test-Engine. With simple JSON files you can run tests for all your RESTful API's.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Kristof Friess

api test restful