BerryCrush Documentation

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

Features

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 6 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"])
@BerryCrushSpec(paths = ["petstore.yaml"])
@BerryCrushConfiguration(bindings = PetStoreBindings::class)
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:1.0.0")
    testImplementation("org.berrycrush.berrycrush:junit:1.0.0")
    // For Spring Boot projects
    testImplementation("org.berrycrush.berrycrush:spring:1.0.0")
}

Indices and tables