Skip to content

RAML Testing and Abao

plroebuck edited this page Apr 6, 2016 · 2 revisions

RAML Testing and Abao

The basic idea of RAML test is according to the input definition parameters in the RAML initiated requests to back-end, and then do the verification between the response schema defined in the RAML and the response returned by back-end .

Abao is also based on this principle, it reads the information in the RAML generated Test Case, transmit defined example in RAML to Backend, and then do the comparison between result return from backend and schema in RAML. The development of Test Case and the maintenance cost is greatly reduced.

Abao automatically generated Test Case belongs to the Acceptance Testing category. Verify the specific logic can be implemented in after hook, agree with the expected value such as a field.

Terms

Test Case

The RAML for each Response corresponds to a Test Case. Test Case automatically generated by Abao according to RAML.

Hooks

Each Test Case has a standard test in the process of before and after hook. The hook provides a trigger corresponding return time, such as the current Test case need to test the return in 404 of cases, it is needed to set up the parameters in the before hook in order to let the backend to return 404.

TDD based backend development with RAML

Make it Red

  1. Write RAML
  2. Run abao and see failed tests result
abao api.raml --server http://localhost:5058

Make it Green

  1. Write the code of the backend application
  2. Write hooks
  3. Run the test again and see it pass

Make it Eternal

And finally – the holy grail! When you plug it into a Continuous Integration system any change of the RAML in your GitHub repository run the test harness. At this point you have always up-to-date API documentation.

Add a Travis dotfile to .travis.yml with:

language: node_js
script: abao api.raml --server http://localhost:5058
services:
- mongodb
before_script:
- mongo abao_example --eval 'db.addUser("test", "test");'