Skip to content

Smocha is a http smoke tests runner focused on simplicity, readability, and speed

Notifications You must be signed in to change notification settings

rodrigodiez/smocha

Repository files navigation

Smocha

Build Status Latest release

Smocha is an http smoke tests runner focused on simplicity, readability, and speed.

In Smocha, tests are defined within yaml files called testbooks that describe an http request and the requirements for the response that comes back.

This configuration over code approach helps not only to standardize procedures and terminology across teams but also to better understand a test suite at a glance.

Smocha run

Smocha is written in Go and inspired by so many other projects such as Cucumber and Ansible.

Smocha is under heavy development at the moment and while we adhere to Semantic versioning there are plans to update the testbook yaml structure in the next major version. Bear this in mind when updating your Smocha binary since your old testbooks may stop working properly. Please read #6 for more details

Features

  • Concurrent, throttled http(s) tests
  • Non-zero exit code on failure
  • Stderr for errors
  • Summary of execution
  • Partial overrides of testbooks using environment variables

Testbook example

host: myhost.com
schema: https
rate: 20
tests:
- url: /
  should:
    have_status: 200
    contain: success
    have_headers:
      - { name: 'Content-Type', value: 'application/javascript'}
      - { name: 'X-Custom-Header', value: 'foo'}

- url: /json-endpoint
  should:
    have_status: 200
    match_json_schema: ./MyOwnSchema.schema.json

Installation

Go get

go get -u github.com/rodrigodiez/smocha

Binary download

Binaries for Linux, macOS and Windows are available in the releases section of this repository

Brew

Brew installation is not available yet but it will be ready soon. Check #6 for updated details

Running Smocha

# testbook file defaults to testbook.yml if not specified
smocha

# you can specify a custom filename
smocha my-testbook-file.yml

# you can also override some testbook values using environment variables
env SMOCHA_HOST=google.com smocha