DavidTolley / apigoldfileexample

Example for API Contract Tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Contract Testing: Dynamic API Contract tests based on API Goldfiles

API Goldfiles are a way to ensure API contracts are honored at all times:

  • Goldfiles live in the directory:
    • /src/main/resources/goldfiles
  • Goldfiles are defined in yml format, example:
tests: [
    {
        name: Verify querying by city name matches 'name' attribute in response
        api_endpoint: "/data/2.5/weather?q=London"
        method: GET
        response: {
            name: "London"
        }
    }
]

To run API Contract Testing you need to do the following:

  • Docker must be installed
  • Clone this repo
  • Set ENV variables:
  • Run the following command:
    • ./run_tests.sh
  • Test results will be available in the directory with junit format:
    • results.xml
  • Test HTML report will be available in:
    • report

About

Example for API Contract Tests


Languages

Language:Java 95.8%Language:Shell 3.6%Language:Dockerfile 0.6%