diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..cae8353
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,69 @@
+name: Tests
+
+permissions:
+ contents: read
+
+on:
+ push:
+ branches: [ "main" ]
+ paths:
+ - 'backend/**'
+ - '.github/workflows/test.yml'
+ pull_request:
+ branches: [ "main" ]
+ paths:
+ - 'backend/**'
+ - '.github/workflows/test.yml'
+
+jobs:
+ unit-tests:
+ name: Unit Tests
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4
+ with:
+ java-version: '21'
+ distribution: 'temurin'
+ cache: maven
+
+ - name: Run unit tests
+ working-directory: backend
+ run: mvn -B test -Dtest='!*IT,!*IntegrationTest' --fail-at-end
+
+ - name: Upload unit test results
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: unit-test-results
+ path: backend/target/surefire-reports/
+ retention-days: 7
+
+ integration-tests:
+ name: Integration Tests
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4
+ with:
+ java-version: '21'
+ distribution: 'temurin'
+ cache: maven
+
+ - name: Run integration tests
+ working-directory: backend
+ run: mvn -B test -Dtest='*IT,*IntegrationTest' -Dspring.profiles.active=test --fail-at-end
+
+ - name: Upload integration test results
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: integration-test-results
+ path: backend/target/surefire-reports/
+ retention-days: 7
diff --git a/backend/pom.xml b/backend/pom.xml
index f19d1ff..d142d7f 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -75,6 +75,11 @@
spring-boot-starter-test
test
+
+ org.springframework.security
+ spring-security-test
+ test
+
org.springframework.boot
spring-boot-starter-security
diff --git a/backend/src/test/java/com/angel/autonow/ExampleControllerIT.java b/backend/src/test/java/com/angel/autonow/ExampleControllerIT.java
new file mode 100644
index 0000000..8910b18
--- /dev/null
+++ b/backend/src/test/java/com/angel/autonow/ExampleControllerIT.java
@@ -0,0 +1,30 @@
+package com.angel.autonow;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.web.servlet.MockMvc;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+@SpringBootTest
+@AutoConfigureMockMvc
+@ActiveProfiles("test")
+class ExampleControllerIT {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @Test
+ @DisplayName("GET /api/test should return hello")
+ void shouldReturnHello() throws Exception {
+ mockMvc.perform(get("/api/test"))
+ .andExpect(status().isOk())
+ .andExpect(content().string("hello"));
+ }
+}
diff --git a/backend/src/test/java/com/angel/autonow/ExampleControllerTest.java b/backend/src/test/java/com/angel/autonow/ExampleControllerTest.java
new file mode 100644
index 0000000..433f0cc
--- /dev/null
+++ b/backend/src/test/java/com/angel/autonow/ExampleControllerTest.java
@@ -0,0 +1,14 @@
+package com.angel.autonow;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class ExampleControllerTest {
+
+ @Test
+ void exampleEndpoint() {
+ String result = new ExampleController().exampleEndpoint();
+ assertEquals("hello", result);
+ }
+}
\ No newline at end of file
diff --git a/backend/src/test/java/com/angel/autonow/security/TestSecurityConfig.java b/backend/src/test/java/com/angel/autonow/security/TestSecurityConfig.java
deleted file mode 100644
index 16f6a12..0000000
--- a/backend/src/test/java/com/angel/autonow/security/TestSecurityConfig.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.angel.autonow.security;
-
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
-import org.springframework.security.web.SecurityFilterChain;
-
-@TestConfiguration
-public class TestSecurityConfig {
-
- @Bean
- SecurityFilterChain testFilterChain(HttpSecurity http) throws Exception {
- return http
- .csrf(AbstractHttpConfigurer::disable)
- .authorizeHttpRequests(auth -> auth.anyRequest().permitAll())
- .build();
- }
-}
\ No newline at end of file