Bake Test IntegrationGuidesGetting Started

Getting Started

This guide explains how to run Docker Compose integration test scenarios consistently with bake-test-integration.

Installation

Add the gem to your project:

$ bundle add bake-test-integration

Integration Test Layout

Place each independent scenario in its own directory with a docker-compose.yaml file:

integration/
  cluster/
    docker-compose.yaml
  sentinel/
    docker-compose.yaml

Each Compose project should expose a tests service whose exit status determines whether the scenario passed.

Running Integration Tests

Run every scenario in directory-name order:

$ bake test:integration

Run one scenario:

$ bake test:integration name=cluster

The task runs docker compose up --build --exit-code-from tests from each scenario directory. It then runs docker compose down --volumes --remove-orphans, including after a failed test.

Environment variables such as RUBY_VERSION and COVERAGE are inherited by Docker Compose.

Collecting Coverage

Coverage collection remains the responsibility of the test process inside the container. To collect coverage with Covered, bind-mount the project into the test container, run the tests from the project root, and pass COVERAGE through to the container:

services:
  tests:
    image: ruby:${RUBY_VERSION:-latest}
    volumes:
      - ../..:/code
    working_dir: /code
    command: bundle exec sus integration/cluster/test
    environment:
      - COVERAGE=${COVERAGE}

Covered writes .covered.db into the mounted project root, making it available to the host or CI runner after Compose exits. When scenarios run in separate CI jobs, upload each database under a distinct artifact name and combine them during coverage validation:

$ bundle exec bake covered:validate --paths */.covered.db \;

Artifact upload and download are intentionally CI-provider-specific. bake-test-integration only preserves the environment and lifecycle needed for the container to produce the database.

Options

Use a different test service:

$ bake test:integration service=runner

Skip image builds:

$ bake test:integration build=false

Use a different scenario directory:

$ bake test:integration path=system-tests