BerryCrush Documentation
BerryCrush is an OpenAPI-driven BDD-style API testing library for Kotlin and Java.
Getting Started
Features
- Scenario File Syntax
- Auto-Generated Tests
- Kotlin DSL
- Overview
- Quick Start
- Creating a Test Suite
- Defining Scenarios
- API Calls
- Variable Extraction
- Assertions
- Conditionals
- Scenario File Compatibility
- Scenario Outlines
- Fragments (Reusable Steps)
- JUnit Integration
- Complete Example
- API Reference
- JUnit 5 Integration with BerryCrushExtension
- @ScenarioTest Annotation
- Auto-Test Generation
- See Also
- Standalone Runner
- File-Level Parameters
- Scenario-Level Parameters
- Feature-Level Parameters
- Parameter Inheritance
- Variable References in Parameters
- Parallel Execution
- Retry
- Enhanced Error Context
- Plugins
- Custom Steps
- Reporting
- Multi-Spec OpenAPI Support
- Fragments
- Spring Boot Integration
- HTTP Logging
Guides
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
Parallel execution: Run scenarios concurrently with thread-safe isolation
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.1.0-SNAPSHOT")
testImplementation("org.berrycrush.berrycrush:junit:1.1.0-SNAPSHOT")
// For Spring Boot projects
testImplementation("org.berrycrush.berrycrush:spring:1.1.0-SNAPSHOT")
}
Add to your build.gradle:
dependencies {
testImplementation 'org.berrycrush.berrycrush:core:1.1.0-SNAPSHOT'
testImplementation 'org.berrycrush.berrycrush:junit:1.1.0-SNAPSHOT'
// For Spring Boot projects
testImplementation 'org.berrycrush.berrycrush:spring:1.1.0-SNAPSHOT'
}
Add to your pom.xml:
<dependencies>
<dependency>
<groupId>org.berrycrush.berrycrush</groupId>
<artifactId>core</artifactId>
<version>1.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.berrycrush.berrycrush</groupId>
<artifactId>junit</artifactId>
<version>1.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- For Spring Boot projects -->
<dependency>
<groupId>org.berrycrush.berrycrush</groupId>
<artifactId>spring</artifactId>
<version>1.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>