Test Organization
Vespa’s tests are organized by technology and scope:Java Unit Tests
JUnit-based tests in
src/test/java/ directoriesC++ Unit Tests
Google Test-based tests in
src/tests/ directoriesShell Script Tests
BATS framework tests in
.bats filesSystem Tests
End-to-end tests in separate repository
Running Java Tests
Run All Tests
Run Tests for Specific Module
Run Specific Test Class
Run Specific Test Method
Skip Tests During Build
Running C++ Tests
C++ tests are built using CMake and run with CTest.Build and Run Tests
Run Specific C++ Tests
Valgrind Testing
Run tests under Valgrind to detect memory issues:NO_VALGRIND parameter in vespa_add_test.
Benchmark Tests
Benchmark tests are only run when explicitly enabled:Running Shell Script Tests
Vespa uses BATS for testing shell scripts.Setup BATS
- macOS
- AlmaLinux/Docker
~/.zshrc or ~/.bashrc to persist.Run Shell Tests
IntelliJ Integration
Shell tests can be run directly in IntelliJ IDEA:- Install the BashSupport Pro plugin
- Ensure
BATS_PLUGIN_PATHis exported before launching IntelliJ - Right-click on
.batsfiles and select “Run”
Writing Tests
Writing Java Tests
Java tests use JUnit and are placed insrc/test/java/ matching the package structure:
- Test classes should end with
Test - One test class per production class
- Use descriptive test method names
- Test both success and error cases
- Keep tests fast and independent
Writing C++ Tests
C++ tests use Google Test framework. Add test definitions toCMakeLists.txt:
Writing Shell Script Tests
Create.bats files with test cases:
assert_success- Exit code is 0assert_failure- Exit code is non-zeroassert_output "text"- Exact output matchassert_output --partial "text"- Partial matchassert_line "text"- Line matches exactlyassert_equal "$expected" "$actual"- Values are equal
System Tests
System tests are in a separate repository: vespa-engine/system-test These tests:- Verify end-to-end functionality
- Test multi-node configurations
- Validate production-like scenarios
- Run in continuous integration
Test Configuration
Maven Surefire (Java)
Configure test execution inpom.xml:
CTest (C++)
Set test properties:Continuous Integration
Vespa uses Buildkite for CI:- All tests run on every commit
- Tests must pass before merging
- Performance benchmarks track regressions
- Coverage reports available
Troubleshooting
Tests fail with OutOfMemoryError
Tests fail with OutOfMemoryError
Increase memory for Maven tests:Or set
MAVEN_OPTS:CTest shows no tests found
CTest shows no tests found
Ensure tests were built:
BATS tests fail to load plugins
BATS tests fail to load plugins
Verify
BATS_PLUGIN_PATH is set:Tests pass locally but fail in CI
Tests pass locally but fail in CI
Common causes:
- Environment differences (paths, dependencies)
- Timing issues (tests may be slower in CI)
- Resource constraints (less memory/CPU)
- Test interdependencies
Performance Testing
For performance-critical changes:- Write benchmark tests using
BENCHMARKflag - Compare results before and after changes
- Document performance implications in PR
- Monitor CI performance metrics
Next Steps
Code Map
Navigate the codebase to find what to test
Building Vespa
Build Vespa before running tests
Development Overview
Return to development overview
System Tests
Contribute to system tests