Giter Site home page Giter Site logo

el_petstore's Introduction

API tests

A Postman collection with API tests for https://petstore.swagger.io/

Prerequisites

Docker or Neman or Postman Desktop

Run the tests using Docker

Run Postman collection using newman in a docker container. In project directory run:

docker build -t postman-runner:latest .
docker run --rm postman-runner:latest run "./collections/PetStore_API_Tests.postman_collection.json" -e "./environments/PetStore_prod.postman_environment.json"

Run the tests using newman

In project directory run:

newman run "./collections/PetStore_API_Tests.postman_collection.json" -e "./environments/PetStore_prod.postman_environment.json"

Run the tests in Postman Desktop app

Open Postman. Import collection and environment (File -> Import -> path to the file). Click Runner. Select the collection and environment. Click Run.

Testing Notes

The expected output should contain assertion errors (I created tests in such a way that some of them fail) and be something like this:

┌─────────────────────────┬─────────────────────┬────────────────────┐
│                         │            executed │             failed │
├─────────────────────────┼─────────────────────┼────────────────────┤
│              iterations │                   1 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│                requests │                   9 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│            test-scripts │                  14 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│      prerequest-scripts │                  11 │                  0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│              assertions │                  21 │                  5 │
├─────────────────────────┴─────────────────────┴────────────────────┤
│ total run duration: 2.7s                                           │
├────────────────────────────────────────────────────────────────────┤
│ total data received: 916B (approx)                                 │
├────────────────────────────────────────────────────────────────────┤
│ average response time: 226ms [min: 149ms, max: 834ms, s.d.: 214ms] │
└────────────────────────────────────────────────────────────────────┘

  #  failure                                    detail                                                                                                                                                                
                                                                                                                                                                                                                      
 1.  AssertionError                             Payload complies to schema
                                                expected data to satisfy schema but found following errors: 
                                                data should have required property 'code', data should have required property 'type', data should have required property 'message'
                                                at assertion:0 in test-script
                                                inside "Create pet: missing required field "name""
                                                                                                                                                                                                                      
 2.  AssertionError                             Status code is 400
                                                expected response to have status code 400 but got 200
                                                at assertion:1 in test-script
                                                inside "Create pet: missing required field "name""
                                                                                                                                                                                                                      
 3.  AssertionError                             Error message is as expected
                                                expected undefined to equal 'Missing required field: name'
                                                at assertion:2 in test-script
                                                inside "Create pet: missing required field "name""
                                                                                                                                                                                                                      
 4.  AssertionError                             Status code is 400
                                                expected response to have status code 400 but got 404
                                                at assertion:1 in test-script
                                                inside "Delete order: txt id"
                                                                                                                                                                                                                      
 5.  AssertionError                             Response contains expected data
                                                name is incorrect: expected 'doggie' to equal 'el-pet-9904ef74'
                                                at assertion:2 in test-script
                                                inside "Find pet by Id: complex example"

el_petstore's People

Contributors

tellet avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.