diff --git a/.github/workflows/develop_pull_request.yml b/.github/workflows/develop_pull_request.yml index 1af5919..7d8e2cc 100644 --- a/.github/workflows/develop_pull_request.yml +++ b/.github/workflows/develop_pull_request.yml @@ -43,6 +43,10 @@ jobs: -p 6379:6379 \ redis:7.0 + - name: Setup .env + run: | + echo "${{ secrets.TEST_ENV }}" >> .env + - name: Grant Execute Permission for Gradlew run: chmod +x ./gradlew diff --git a/src/test/java/com/ject/studytrip/BaseIntegrationTest.java b/src/test/java/com/ject/studytrip/BaseIntegrationTest.java new file mode 100644 index 0000000..d975258 --- /dev/null +++ b/src/test/java/com/ject/studytrip/BaseIntegrationTest.java @@ -0,0 +1,23 @@ +package com.ject.studytrip; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +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.context.TestPropertySource; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest(classes = {StudytripApplication.class}) +@ActiveProfiles("test") +@TestPropertySource(locations = "file:.env") +@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) +@Transactional +@AutoConfigureMockMvc +public abstract class BaseIntegrationTest { + + @Autowired protected MockMvc mockMvc; + @Autowired protected ObjectMapper objectMapper; +} diff --git a/src/test/java/com/ject/studytrip/BaseUnitTest.java b/src/test/java/com/ject/studytrip/BaseUnitTest.java new file mode 100644 index 0000000..09c83e6 --- /dev/null +++ b/src/test/java/com/ject/studytrip/BaseUnitTest.java @@ -0,0 +1,11 @@ +package com.ject.studytrip; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public abstract class BaseUnitTest { + + protected final ObjectMapper objectMapper = new ObjectMapper(); +}