JSON Automation Test Case via Postman
* to fail fast
* to avoid data corruption
* to simplify processing code
* to use validation code in tests
* as wide adoption as XML
* easier to process and more concise than XML
* dominates web development because of JavaScript
* declarative
* easier to maintain
* can be understood by non-coders
* no need to write code, third party open-source libraries can be used
* the widest adoption among all standards for JSON validation
* very mature (current version is 4, there are proposals for version 5)
* covers a big part of validation scenarios
* uses easy-to-parse JSON documents for schemas
* platform independent
* easily extensible
* 30+ validators for different languages, including 10+ for JavaScript, so no need to code it yourself
* tested result
* easy to learn from simple to complex condition
* using schema references to validate the response
* using external library PostmanBDD not only TinyValidator (tv4)
- Install postman.
- Install tv4 (Tiny Validator).
- npm install tv4
- Install ajv (Another JSON Schema Validator).
- npm install ajv
- Copy & paste the testcase script on tab "test" postman.
- Done.
- Import the collection in folder "collection", or
- Download ZeroC0D3 Collection : https://www.getpostman.com/collections/7f63ef54d405bfe2f1db
- Click "Runner" button and select the "ZeroC0D3 TestCase API",
- Click "Start Runner" button.
- Done.
- Download test result "ZeroC0D3_Result.json" in folder "collection".
- Install newman
- npm install -g newman
- Open your terminal / command,
- Running newman command
- newman -c ZeroC0D3_Result.json
- Done.
- http://blog.getpostman.com/2014/03/07/writing-automated-tests-for-apis-using-postman/
- http://blog.getpostman.com/2014/04/17/how-to-write-automated-tests-for-apis-with-postman-part-2/
- https://github.com/geraintluff/tv4
- http://geraintluff.github.com/tv4/
- https://github.com/BigstickCarpet/postman-bdd
- https://spacetelescope.github.io/understanding-json-schema/structuring.html
- http://chaijs.com/plugins/chai-json-schema/
- https://code.tutsplus.com/tutorials/validating-data-with-json-schema-part-1--cms-25343
- https://code.tutsplus.com/tutorials/validating-data-with-json-schema-part-2--cms-25640