-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: 테스트 최적화 #867
refactor: 테스트 최적화 #867
Changes from all commits
08adaeb
873d16e
3dddbd6
cd4a38b
03e7d43
c9020b7
70bcaf0
116044f
cc6d69d
990340b
0968158
6a0934d
c15aa33
8bf2904
e836f23
091b2ff
4d3e770
4565eea
482e68b
79c9d0d
7cc253e
feea3b4
943ebfa
1786f38
7977dac
e894bcd
8e6191e
16a1126
ba0ffa7
2bb3f35
b26f813
f7e1763
649a45d
51ad0fd
e45b01e
bd8fcd8
4e7d0c0
fd03540
78b99f9
4804fce
93d563e
92d11a0
2ad37cc
ca77bb4
153b529
00d6e3c
1327e4f
ddcd062
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,6 @@ default Menu getById(Integer menuId) { | |
} | ||
|
||
List<Menu> findAllByShopId(Integer shopId); | ||
|
||
List<Menu> findAll(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
package in.koreatech.koin; | ||
|
||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; | ||
|
||
import java.time.Clock; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
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.boot.test.mock.mockito.MockBean; | ||
import org.springframework.boot.test.mock.mockito.SpyBean; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.springframework.test.context.DynamicPropertySource; | ||
import org.springframework.test.context.transaction.TestTransaction; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.MySQLContainer; | ||
import org.testcontainers.junit.jupiter.Container; | ||
|
@@ -28,21 +28,21 @@ | |
import in.koreatech.koin.domain.shop.model.ReviewEventListener; | ||
import in.koreatech.koin.domain.shop.model.ShopEventListener; | ||
import in.koreatech.koin.domain.user.model.StudentEventListener; | ||
import in.koreatech.koin.util.TestCircuitBreakerClient; | ||
import in.koreatech.koin.support.DBInitializer; | ||
import io.restassured.RestAssured; | ||
import in.koreatech.koin.util.TestCircuitBreakerClient; | ||
import jakarta.persistence.EntityManager; | ||
|
||
@SpringBootTest(webEnvironment = RANDOM_PORT) | ||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
@Import({DBInitializer.class, TestJpaConfiguration.class, TestTimeConfig.class, TestRedisConfiguration.class}) | ||
@ActiveProfiles("test") | ||
public abstract class AcceptanceTest { | ||
|
||
private static final String ROOT = "test"; | ||
private static final String ROOT_PASSWORD = "1234"; | ||
|
||
@LocalServerPort | ||
protected int port; | ||
@Autowired | ||
public MockMvc mockMvc; | ||
|
||
@MockBean | ||
protected OwnerEventListener ownerEventListener; | ||
|
@@ -97,29 +97,37 @@ private static void configureProperties(final DynamicPropertyRegistry registry) | |
|
||
static { | ||
mySqlContainer = (MySQLContainer)new MySQLContainer("mysql:8.0.29") | ||
.withDatabaseName("test") | ||
.withUsername(ROOT) | ||
.withPassword(ROOT_PASSWORD) | ||
.withCommand("--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"); | ||
.withDatabaseName("test") | ||
.withUsername(ROOT) | ||
.withPassword(ROOT_PASSWORD) | ||
.withCommand("--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"); | ||
|
||
redisContainer = new GenericContainer<>( | ||
DockerImageName.parse("redis:7.0.9")) | ||
.withExposedPorts(6379); | ||
DockerImageName.parse("redis:7.0.9")) | ||
.withExposedPorts(6379); | ||
|
||
mongoContainer = new GenericContainer<>( | ||
DockerImageName.parse("mongo:6.0.14")) | ||
.withExposedPorts(27017); | ||
DockerImageName.parse("mongo:6.0.14")) | ||
.withExposedPorts(27017); | ||
|
||
mySqlContainer.start(); | ||
redisContainer.start(); | ||
mongoContainer.start(); | ||
} | ||
|
||
@BeforeEach | ||
void delete() { | ||
if (RestAssured.port == RestAssured.UNDEFINED_PORT) { | ||
RestAssured.port = port; | ||
} | ||
void initIncrement() { | ||
dataInitializer.initIncrement(); | ||
dataInitializer.clearRedis(); | ||
} | ||
Comment on lines
+119
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A
|
||
|
||
protected void clear() { | ||
dataInitializer.clear(); | ||
} | ||
Comment on lines
+124
to
126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A이것도 어떤 걸 clear하는지 명시하면 좋겠어요 (ex. |
||
|
||
protected void forceVerify(Runnable runnable) { | ||
TestTransaction.flagForCommit(); | ||
TestTransaction.end(); | ||
runnable.run(); | ||
} | ||
Comment on lines
+128
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A이건 어떤 용도인가요? |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
잘 몰라서 혹시 테스트 최적화와 관련있는 내용인가요?