Tomato is a language agnostic testing tool kit that simplifies the acceptance testing workflow of your application and its dependencies.
Using godog and Gherkin, tomato makes behavioral tests easier to understand, maintain, and write for developers, QA, and product owners.
- Cucumber Gherkin feature syntax
- Support for MySQL, MariaDB, and PostgreSQL
- Support for messaging queues (RabbitMQ, NSQ)
- Support for mocking HTTP API responses
- Additional resources resources
Tomato integrates your app and its test dependencies using a simple configuration file tomato.yml
.
Create a tomato.yml
file with your application's required test resources:
---
resources:
- name: psql
type: database/sql
params:
driver: postgres
datasource: {{ .PSQL_DATASOURCE }}
- name: your-application-client
type: http/client
params:
base_url: {{ .APP_BASE_URL }}
Write your own Gherkin feature (or customize the check-status.feature example below) and place it inside ./features/check-status.feature:
Feature: Check my application's status endpoint
Scenario: My application is running and active
Given "your-application-client" send request to "GET /status"
Then "your-application-client" response code should be 200
Now that you have your resources configured, you can use docker-compose to run tomato in any Docker environment (great for CI and other build pipelines).
Create a docker-compose.yml
file, or add tomato and your test dependencies to an existing one:
version: '3'
services:
tomato:
image: quay.io/alileza/tomato:latest
environment:
APP_BASE_URL: http://my-application:9000
PSQL_DATASOURCE: "postgres://user:password@postgres:5432/test-database?sslmode=disable"
volumes:
- ./tomato.yml:/config.yml # location of your tomato.yml
- ./features/:/features/ # location of all of your features
my-application:
build: .
expose:
- "9000"
postgres:
image: postgres:9.5
expose:
- "5432"
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: test-database
volumes:
- ./sqldump/:/docker-entrypoint-initdb.d/ # schema or migrations sql
Execute your tests
docker-compose up --abort-on-container-exit
Install tomato by grabbing the latest stable release and placing it in your path, or by using go get
go get -u github.com/alileza/tomato/cmd/tomato
Now run tomato:
tomato -c tomato.yml -f check-status.feature
Resource are the objects that are going to be used for steps in the scenario. They are listed under the resources key in the pipeline configuration.
- Database SQL - to manage (insert/check) database state changes
- HTTP Client - to send HTTP Request
- HTTP Server - to create fake external service dependency that serve HTTP API
- Message Queue - to manage (publish/consume/check) message queue
- Shell - to execute unix shell command-line interface