diff --git a/.gitea/workflows/api-gateway.yml b/.gitea/workflows/api-gateway.yml index 84a6503..1aa5244 100644 --- a/.gitea/workflows/api-gateway.yml +++ b/.gitea/workflows/api-gateway.yml @@ -66,12 +66,28 @@ jobs: - name: Run unit tests run: ./mvnw test + - name: Check test reports + run: | + echo "Checking for test report files..." + if [ -d "target/surefire-reports" ]; then + echo "Surefire reports directory exists" + ls -la target/surefire-reports/ + if [ -n "$(find target/surefire-reports -name '*.xml' -type f)" ]; then + echo "✅ Found test report XML files" + else + echo "⚠️ No XML files found in surefire-reports" + fi + else + echo "❌ Surefire reports directory does not exist" + fi + - name: Generate test report uses: dorny/test-reporter@v1 - if: success() || failure() + if: always() && (success() || failure()) + continue-on-error: true with: name: Maven Tests (Java ${{ matrix.java-version }}) - path: services/api-gateway/target/surefire-reports/*.xml + path: target/surefire-reports/*.xml reporter: java-junit - name: Run code quality checks diff --git a/services/api-gateway/pom.xml b/services/api-gateway/pom.xml index cb59c63..02240f0 100644 --- a/services/api-gateway/pom.xml +++ b/services/api-gateway/pom.xml @@ -55,6 +55,13 @@ postgresql runtime + + + + com.h2database + h2 + test + diff --git a/services/api-gateway/src/test/java/com/labfusion/LabFusionApiGatewayApplicationTests.java b/services/api-gateway/src/test/java/com/labfusion/LabFusionApiGatewayApplicationTests.java new file mode 100644 index 0000000..e79df0f --- /dev/null +++ b/services/api-gateway/src/test/java/com/labfusion/LabFusionApiGatewayApplicationTests.java @@ -0,0 +1,18 @@ +package com.labfusion; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +@SpringBootTest +@ActiveProfiles("test") +class LabFusionApiGatewayApplicationTests { + + @Test + void contextLoads() { + // This test verifies that the Spring context loads successfully + assertTrue(true, "Spring context should load successfully"); + } +} diff --git a/services/api-gateway/src/test/resources/application.yml b/services/api-gateway/src/test/resources/application.yml new file mode 100644 index 0000000..4e4c098 --- /dev/null +++ b/services/api-gateway/src/test/resources/application.yml @@ -0,0 +1,30 @@ +spring: + application: + name: labfusion-api-gateway-test + + datasource: + url: jdbc:h2:mem:testdb + driver-class-name: org.h2.Driver + username: sa + password: + + jpa: + hibernate: + ddl-auto: create-drop + show-sql: false + properties: + hibernate: + format_sql: false + + h2: + console: + enabled: true + +server: + port: 0 # Random port for tests + +logging: + level: + com.labfusion: DEBUG + org.springframework: WARN + org.hibernate: WARN