-
Notifications
You must be signed in to change notification settings - Fork 59
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.
The RAML for each Response corresponds to a Test Case. Test Case automatically generated by Abao according to RAML.
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.
- Write RAML
- Run abao and see failed tests result
abao api.raml --server http://localhost:5058
- Write the code of the backend application
- Write hooks
- Run the test again and see it pass
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");'