Skip to content

Latest commit

 

History

History
67 lines (53 loc) · 1.63 KB

File metadata and controls

67 lines (53 loc) · 1.63 KB

Create Specs

Testing running API

Continuous testing on an existing API for which you have a swagger spec can be done with Dredd

mkdir swagger
wget https://example.com/dist/swagger.json

Install npm tools

npm --version
npm install json2yaml
npm install dredd
npm install junit-viewer

Convert json to yml as dredd reads only yml

./node_modules/json2yaml/cli.js ./swagger/swagger.json > ./swagger/swagger.yml

Create ./dredd.yml. Ensure to set the user field with proper credentials

---
dry-run: null
hookfiles: null
language: nodejs
sandbox: false
server: null
server-wait: 3
init: false
custom: {}
names: false
only: []
reporter: xunit
output: dredd-output.xml
header: []
sorted: false
user: <username>:<password>
inline-errors: false
details: true
method: []
color: true
level: info
timestamp: true
silent: false
path: []
hooks-worker-timeout: 5000
hooks-worker-connect-timeout: 1500
hooks-worker-connect-retry: 500
hooks-worker-after-connect-wait: 100
hooks-worker-term-timeout: 5000
hooks-worker-term-retry: 500
hooks-worker-handler-host: 127.0.0.1
hooks-worker-handler-port: 61321
config: ./dredd.yml
blueprint: ./swagger/swagger.yml
endpoint: 'https://example.com'

Run dredd

./node_modules/dredd/bin/dredd --config dredd.yml

View dredd results

./node_modules/junit-viewer/bin/junit-viewer --results=dredd-output.xml --save=junit.html && firefox junit.html