How to Run the Test Suite
Kleinkram comes with various test suites to ensure the quality of the codebase. This document explains how to run the test suite.
Running the Test Suite
Currently, we are only testing the API, those test cases are located in the backend/tests directory. You can run the test suite by first starting the application stack in test mode and then running the tests.
# clear any previous test containers and volumes
docker compose -f docker-compose.testing.yml down --volumes
# start the application stack in test mode
docker compose -f docker-compose.testing.yml up --build [--watch]INFO
This command will start the application stack in test mode and optionally watches for changes in the codebase.
You can then run the tests by executing the following command:
yarn run test[:verbose]INFO
The :verbose flag is optional and will output more information about the test results.
How do the Tests Work?
Some of the tests directly interact with the database in order to seed the database with test data. Thus, it is important to run the tests in a separate environment to avoid data corruption in the development or production environment.
Automated CLI Testing
For automated testing of CLI commands, you can use the fake OAuth provider with the --user parameter to automatically authenticate without browser interaction:
# Authenticate as admin user
klein login --oauth-provider fake-oauth --user 1
# Run your CLI commands
klein project list
klein file list
# Test with different user permissions
klein login --oauth-provider fake-oauth --user 2
klein project create --name "Test Project"This is particularly useful for:
- CI/CD pipelines
- Integration tests
- Automated scripts
- Testing different permission levels
See the Fake OAuth Provider documentation for more details on available users.
CLI Test Data
The CLI tests require specific test data (ROS bag files) to be present. These files are automatically generated by a script.
To generate the test data manually:
# Install dependencies
pip install rosbags
# Generate data
python3 cli/tests/generate_test_data.pyThis will create the necessary .bag files in cli/tests/data and backend/tests/fixtures.
End-to-End Testing
End-to-end testing is currently not implemented. We are planning to implement end-to-end tests in the future.
WARNING
End-to-end tests are not implemented yet. We are planning to use Cypress for end-to-end testing.