Introducing Silk: Markdown driven API tests

The problem

Documentation also quickly gets out of sync as the APIs evolve.

Meet Silk

Silk lets you write Markdown documentation for your APIs, and then execute as an automated test.

Tutorial

# Hello API## `GET /hello`Gets a personalised greeting.* `?name=Mat` // The name of the person to greet===* Status: `404````
Hello there
```
Markdown renders nicely to look like real API documentation.
$ silk -silk.url=”http://outlearn-hello.appspot.com" hello-api.silk.md
running 1 file(s)
body expected:
```
Hello there
```
actual:
```
Hello Mat.
```
— — FAIL: GET /hello
hello-api.silk.md:14 — body doesn’t match
— — FAIL: silk (0.31s)
FAIL
# Hello API## `GET /hello`Gets a personalised greeting.* `?name=Mat` // The name of the person to greet===* Status: `404````
Hello Mat.
```
$ silk -silk.url=”http://outlearn-hello.appspot.com" hello-api.silk.mdrunning 1 file(s)
Status expected: 404 actual: 200
— — FAIL: GET /hello
hello-api.silk.md:11 — Status doesn’t match
— — FAIL: silk (1.24s)
FAIL
# Hello API## `GET /hello`Gets a personalised greeting.* `?name=Mat` // The name of the person to greet===* Status: `200`
* Content-Type: `text/html; charset=utf-8`
```
Hello Mat.
```
$ silk -silk.url=”http://outlearn-hello.appspot.com" hello-api.silk.mdrunning 1 file(s)PASS

Conclusion

Founder at MachineBox.io — Gopher, developer, speaker, author — BitBar app https://getbitbar.com — Author of Go Programming Blueprints

Founder at MachineBox.io — Gopher, developer, speaker, author — BitBar app https://getbitbar.com — Author of Go Programming Blueprints