To check that all your unit tests pass locally before pushing to GitHub, you have several options:
Run all tests across modules
From your root project directory (where the parent pom.xml is located):
mvn clean test
This will run all unit tests in all modules. If any test fails, Maven will stop and report the failure.
Run tests with more details
For more verbose output to see which tests are failing:
mvn clean test -X
Or to continue running even if some tests fail (to see all failures at once):
mvn clean test -Dmaven.test.failure.ignore=true
Run tests for a specific module
If you want to test just one module:
mvn clean test -pl :module-name
Generate test reports
To get a nice HTML report of test results:
mvn clean surefire-report:report
The reports will be in target/site/surefire-report.html for each module.
Check test coverage
If you have JaCoCo configured:
mvn clean test jacoco:report
Verify everything (including integration tests)
If you also have integration tests:
mvn clean verify
Tips for fixing failing tests
- Run tests in your IDE (IntelliJ IDEA or Eclipse) for easier debugging
- Check if tests are failing due to:
- Missing test resources
- Different environment variables locally vs CI
- Timing issues (especially with Camel routes)
- Database/external service dependencies
Since you mentioned the app works but tests fail, common issues with Spring/Camel tests include:
- Missing
@MockBean annotations
- Incorrect test profiles
- Camel routes not properly initialized in test context
- Missing test properties in
application-test.yml
Would you like help debugging specific test failures?