BerryCrush Documentation

BerryCrush is an OpenAPI-driven BDD-style API testing library for Kotlin and Java.

Note

This library is currently in early development. APIs may change.

Features

Reference

Key Features

  • OpenAPI-driven: Automatically validate requests and responses against your OpenAPI spec

  • BDD-style scenarios: Write readable tests using a Gherkin-like DSL

  • Auto-generated tests: Automatically generate invalid request and security tests from OpenAPI schemas

  • JUnit 5 integration: Seamless integration with your existing test infrastructure

  • Spring Boot support: Auto-discover bindings and configuration from Spring context

  • Plugin system: Extend functionality with custom plugins for reporting, logging, and more

  • Custom steps: Define reusable step definitions with annotations, DSL, or registration API

  • Multi-spec support: Work with multiple OpenAPI specifications in a single test suite

  • Fragments: Create reusable scenario steps that can be included across tests

Quick Example

@IncludeEngines("berrycrush")
@BerryCrushScenarios(locations = "scenarios/pet-api.scenario")
@BerryCrushConfiguration(
    bindings = PetStoreBindings::class,
    openApiSpec = "petstore.yaml"
)
class PetApiTest

Scenario file (pet-api.scenario):

scenario: List all pets
  when: I request all pets
    call ^listPets
  then: pets are returned
    assert status 200
    assert schema

Installation

Add to your build.gradle.kts:

dependencies {
    testImplementation("org.berrycrush.berrycrush:core:0.1.0")
    testImplementation("org.berrycrush.berrycrush:junit:0.1.0")
    // For Spring Boot projects
    testImplementation("org.berrycrush.berrycrush:spring:0.1.0")
}

Indices and tables