This guide explains how to run the automated test suite for Security Shepherd.
- Docker and docker-compose installed
- Maven 3.x
- JDK 8 or higher
.envfile configured (copy from project or create one)
Tests use the dotenv library to load database credentials from the .env file. Required variables:
| Variable | Description | Default |
|---|---|---|
TEST_MYSQL_HOST |
MySQL/MariaDB host | 127.0.0.1 |
TEST_MYSQL_PORT |
MySQL/MariaDB port | 3306 |
TEST_MYSQL_PASSWORD |
MySQL root password | Must match DB_PASS |
TEST_MONGO_HOST |
MongoDB host | 127.0.0.1 |
TEST_MONGO_PORT |
MongoDB port | 27017 |
Important: TEST_MYSQL_PASSWORD must match the DB_PASS value used when the database container was created.
Start only the database containers (not the web application):
docker-compose up -d db mongoWait 15-30 seconds for the databases to initialize fully.
docker-compose psYou should see secshep_mariadb and secshep_mongo with status "Up".
mvn testWhen finished:
docker-compose downRun a single test class:
mvn test -Dtest=GetterTestRun multiple test classes:
mvn test -Dtest=GetterTest,SetterTestRun tests matching a pattern:
mvn test -Dtest=*Pool*Some tests will show as "skipped" rather than failed. This happens when:
- Database is not running - Tests that require database connectivity are skipped
- Credentials mismatch -
TEST_MYSQL_PASSWORDdoesn't matchDB_PASS - Connection refused - Database container isn't ready yet
This is intentional behavior. It allows basic unit tests to run even without a full database setup, while integration tests are skipped gracefully.
Tests run: 16, Failures: 0, Errors: 0, Skipped: 11
This indicates 5 tests ran successfully and 11 were skipped (likely database-dependent tests).
The password in your .env file doesn't match what the database was created with. Options:
- Update
TEST_MYSQL_PASSWORDto matchDB_PASS - Or recreate the database volume:
docker-compose down -v
docker-compose up -d db mongoThe database container isn't running or isn't ready:
# Check container status
docker-compose ps
# Check database logs
docker-compose logs db
# Wait and retry
sleep 30
mvn testMake sure Maven picks up the latest code:
mvn clean testThe connection pool tests (ConnectionPoolTest, DatabaseLifecycleListenerTest) verify the HikariCP connection pooling implementation. These tests:
- Require database connectivity for full coverage
- Skip gracefully when database is unavailable
- Always run state-management tests that don't need a database
See database-configuration.md for connection pool configuration details.