diff --git a/.github/workflows/shared-build-and-test.yaml b/.github/workflows/shared-build-and-test.yaml index 414eadc..1507cd1 100644 --- a/.github/workflows/shared-build-and-test.yaml +++ b/.github/workflows/shared-build-and-test.yaml @@ -38,8 +38,25 @@ jobs: - name: Build and run unit tests if: ${{ inputs.vulnerability_scan_only == 'false' }} - run: mvn -B clean compile test working-directory: ${{ inputs.working_dir }} + run: | + mvn -B clean compile test | tee build.log + + tests_run=$(cat build.log | grep "Tests run:" | tail -n 1 | sed 's/.*Tests run: \([0-9]*\).*/\1/') + + echo "DEBUG: tests_run = $tests_run" + + if [ -z "$tests_run" ]; then + echo "WARNING: Could not determine the number of tests run." + tests_run=0 + fi + + if [ "$tests_run" -eq 0 ]; then + echo "ERROR: No tests were run!" + exit 1 + fi + + echo "INFO: $tests_run tests were run!" - name: Generate code coverage if: ${{ inputs.vulnerability_scan_only == 'false' }}