This section covers some high level basic concepts that are important to understand for day to day REST-EZ usage. We highly recommend that you read this page before proceeding to use REST-EZ.
REST-EZ's main purpose is to test HTTP-based APIs without code, and make API testing easy, free and fast for everyone.
Write your API test specification and tell REST-EZ to run them. API test specification is written in YAML and we call each YAML file a test suite, with the option to write Javascript (using any npm
module if needed) to implement custom logic.
REST-EZ is written with parallelism as high priority when running test suites, so your test execution takes as less time as possible.
A test suite has three required sections - meta
, configuration
and specs
.
And optional sections hooks
and spec_dependencies
(you can find more about these optional parts in later sections of the documentation).
meta
SectionSpecify following suite attributes in this section
name
(required attribute)locate_files_relative
(optional attribute)name[String]: Give a name that describes the suite (e.g: like a microservice name)
locate_files_relative[Boolean]: Tells REST-EZ if file paths provided in the suite are relative to suite path or not. If false, REST-EZ will try to find files relative to Node process's current working directory. +If true, REST-EZ will try to find files relative to the suite's path. +Default value is false.
Note: This attribute value applies to every file path you provide in a suite.
configuration
SectionYou can use configuration
section to specify API's host, protocol, port etc. You can also provide a custom Javascript function to custom_configuration
attribute, so it's easy to
+dynamically configure your suite at runtime.
specs
Sectionspecs
section is a list of tests. Each test contains name, request, response validation specification, and a few other additional attributes.
A sample suite for Star Wars API service would look like this:
1linkmeta:
2link name: Star Wars service
3linkconfiguration:
4link scheme: https
5link base_path: /api
6link custom_configuration:
7link run_type: inline
8link inline:
9link function: !!js/function >
10link function() {
11link this.host = 'swapi.co';
12link }
13linkspecs:
14link - name: get Luke Skywalker info
15link request:
16link path: /people/1/
17link method: get
18link response:
19link status_code: 200
20link json_data:
21link - path: $.name
22link value: Luke Skywalker
23link - name: get all Star Wars Films
24link request:
25link path: /films/
26link method: get
27link response:
28link status_code: 200
Next: