Skip to content

Commit b7effba

Browse files
committed
bean 추가
1 parent 1299ccc commit b7effba

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/test/java/com/irum/come2us/domain/cart/CartControllerTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
import java.util.UUID;
2424
import org.junit.jupiter.api.DisplayName;
2525
import org.junit.jupiter.api.Test;
26+
import org.mockito.Mockito;
2627
import org.springframework.beans.factory.annotation.Autowired;
2728
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
2829
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
30+
import org.springframework.boot.test.context.TestConfiguration;
31+
import org.springframework.context.annotation.Bean;
2932
import org.springframework.context.annotation.Import;
3033
import org.springframework.http.MediaType;
3134
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
@@ -43,6 +46,14 @@ class CartControllerTest {
4346
private final UUID mockCartId = UUID.randomUUID();
4447
private final UUID mockOptionValueId = UUID.randomUUID();
4548

49+
@TestConfiguration
50+
static class TestConfig {
51+
@Bean
52+
public CartService cartService() {
53+
return Mockito.mock(CartService.class);
54+
}
55+
}
56+
4657
@Test
4758
@DisplayName("장바구니 추가 API (CUSTOMER)")
4859
void createCartApiTest() throws Exception {

src/test/java/com/irum/come2us/domain/order/OwnerOrderControllerTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
2727
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
28+
import org.springframework.boot.test.context.TestConfiguration;
29+
import org.springframework.context.annotation.Bean;
2830
import org.springframework.context.annotation.Import;
2931
import org.springframework.http.MediaType;
3032
import org.springframework.test.web.servlet.MockMvc;
@@ -38,6 +40,14 @@ public class OwnerOrderControllerTest {
3840
@Autowired private ObjectMapper objectMapper;
3941
@Autowired private OwnerOrderService ownerOrderService;
4042

43+
@TestConfiguration
44+
static class TestConfig {
45+
@Bean
46+
public OwnerOrderService ownerOrderService() {
47+
return Mockito.mock(OwnerOrderService.class);
48+
}
49+
}
50+
4151
// 배송 준비중
4252
@Test
4353
@DisplayName("[상점] 배송 준비 중 목록 조회 API")

0 commit comments

Comments
 (0)