Troubleshooting
This guide covers common issues and their solutions.
Test Discovery Issues
Tests Not Found
Symptom: No tests are discovered by the JUnit runner.
Common Causes:
Missing
@IncludeEngines("berrycrush")annotationIncorrect scenario file paths
Scenario files not on the classpath
Solution:
Ensure your test class has the correct annotations:
@IncludeEngines("berrycrush")
@BerryCrushScenarios(locations = "scenarios/pets.scenario")
class PetApiTest
Verify scenario files are in src/test/resources/.
Scenario Files Not Loaded
Symptom: Test class is discovered but scenarios show as “0 tests”.
Solution:
Check the file extension is
.scenarioVerify the path in
locationsis relative to the resources folderEnsure the file contains valid scenario syntax
// Correct
@BerryCrushScenarios(locations = "scenarios/pets.scenario")
// Also correct - multiple files
@BerryCrushScenarios(locations = [
"scenarios/pets.scenario",
"scenarios/users.scenario"
])
Configuration Issues
Bindings Not Found
Symptom: IllegalStateException: Cannot instantiate bindings class
Solution:
Ensure your bindings class has a public no-arg constructor:
// ✓ Correct
class MyBindings : BerryCrushBindings {
override fun getBindings() = mapOf("key" to "value")
}
// ✗ Wrong - requires constructor argument
class MyBindings(private val config: Config) : BerryCrushBindings {
override fun getBindings() = mapOf("key" to config.value)
}
For dependency injection, use the Spring module:
@Component
class MyBindings(
@Autowired private val config: Config
) : BerryCrushBindings
OpenAPI Spec Not Found
Symptom: FileNotFoundException when loading OpenAPI spec
Solution:
Ensure the spec file is on the classpath:
src/test/resources/
└── petstore.yaml
And reference it correctly:
@BerryCrushConfiguration(
openApiSpec = "petstore.yaml" // Relative to resources root
)
HTTP Request Issues
Connection Refused
Symptom: ConnectException: Connection refused
Solution:
Ensure the API server is running
Verify the baseUrl in bindings is correct
Check for firewall/network issues
class MyBindings : BerryCrushBindings {
override fun getBindings() = mapOf(
"baseUrl" to "http://localhost:8080" // Must match server port
)
}
Timeout Errors
Symptom: Requests timeout
Solution:
Increase timeout in configuration:
@BerryCrushConfiguration(
timeout = 60_000L // 60 seconds
)
SSL/TLS Errors
Symptom: SSLHandshakeException or certificate errors
Solution:
For development/testing with self-signed certificates:
class MyBindings : BerryCrushBindings {
override fun configure(config: Configuration) {
config.sslValidation = false // Disable for testing only
}
}
Warning
Never disable SSL validation in production.
Assertion Failures
JSONPath Not Matching
Symptom: JSONPath assertions fail unexpectedly
Debug Steps:
Print the actual response body
Verify the JSONPath expression
Check data types (string vs number)
scenario: Debug response
when: I request pets
call ^listPets
then: I check the response
assert status 200
assert $.name equals "Fluffy"
Schema Validation Fails
Symptom: SchemaValidationException
Solution:
Compare the actual response against the OpenAPI schema
Check for optional vs required fields
Verify data types match
// Get detailed validation errors
@BerryCrushConfiguration(
pluginClasses = [SchemaValidationPlugin::class]
)
Spring Integration Issues
Bindings Not Injected
Symptom: Spring dependencies are null
Solution:
Ensure you’re using the Spring module and annotations:
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@IncludeEngines("berrycrush")
@BerryCrushScenarios(locations = "scenarios/pets.scenario")
class PetApiTest // Make sure Spring context is initialized
Context Not Available
Symptom: NoSuchBeanDefinitionException
Solution:
Check that the Spring module is included:
dependencies {
testImplementation("org.berrycrush.berrycrush:spring:0.1.0")
}
Plugin Issues
Plugin Not Executing
Symptom: Plugin callbacks are not called
Causes:
Plugin not registered
Exception during plugin initialization
Priority conflicts
Solution:
Add logging to debug:
class DebugPlugin : BerryCrushPlugin {
override val name = "debug"
override val priority = 1000 // High priority, runs first
override fun onScenarioStart(context: ScenarioContext) {
println("Debug: Starting ${context.name}")
}
}
Report Not Generated
Symptom: Report file is empty or missing
Solution:
Check the output path is writable
Verify the plugin is registered
Ensure tests actually ran
@BerryCrushConfiguration(
plugins = ["report:json:build/reports/test.json"]
)
Getting Help
If your issue isn’t listed here:
Check the GitHub Issues for similar problems
Enable debug logging:
-Dberrycrush.debug=trueCreate a minimal reproducing example
Open a new issue with: - BerryCrush version - Kotlin/Java version - Error message and stack trace - Sample code to reproduce