Skip to content

Commit

Permalink
fix: test method 격리
Browse files Browse the repository at this point in the history
  • Loading branch information
DongminL committed Dec 24, 2024
1 parent a33bfc1 commit cad92c1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import org.programmers.signalbuddy.domain.comment.exception.CommentErrorCode;
import org.programmers.signalbuddy.domain.comment.repository.CommentRepository;
import org.programmers.signalbuddy.domain.feedback.dto.FeedbackWriteRequest;
import org.programmers.signalbuddy.domain.feedback.entity.enums.AnswerStatus;
import org.programmers.signalbuddy.domain.feedback.entity.Feedback;
import org.programmers.signalbuddy.domain.feedback.entity.enums.AnswerStatus;
import org.programmers.signalbuddy.domain.feedback.repository.FeedbackRepository;
import org.programmers.signalbuddy.domain.member.MemberRole;
import org.programmers.signalbuddy.domain.member.entity.Member;
Expand All @@ -29,10 +29,13 @@
import org.programmers.signalbuddy.global.support.ServiceTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@TestMethodOrder(OrderAnnotation.class)
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
class CommentServiceTest extends ServiceTest {

@Autowired
Expand Down Expand Up @@ -127,7 +130,7 @@ void writeCommentByAdmin() {
commentService.writeComment(request, user);

// then
Optional<Comment> actual = commentRepository.findById(4L);
Optional<Comment> actual = commentRepository.findById(2L);
SoftAssertions.assertSoftly(softAssertions -> {
softAssertions.assertThat(actual).get().isNotNull();
softAssertions.assertThat(actual.get().getCommentId()).isNotNull();
Expand Down Expand Up @@ -233,7 +236,7 @@ void deleteCommentByAdmin() {

// when
commentService.writeComment(request, user);
commentService.deleteComment(10L, user);
commentService.deleteComment(2L, user);

// then
SoftAssertions.assertSoftly(softAssertions -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.ArrayList;
import java.util.List;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -55,12 +54,6 @@ void setup() {
feedbackRepository.saveAll(feedbackList);
}

@AfterEach
void teardown() {
feedbackRepository.deleteAll();
memberRepository.deleteAll();
}

@DisplayName("탈퇴하지 않은 유저들의 피드백 목록 가져오기")
@Test
void findAllByActiveMembers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public interface MariaDBTestContainer {

@Container
MariaDBContainer<?> MARIADB_CONTAINER = new MariaDBContainer<>("mariadb:10.11")
MariaDBContainer<?> MARIADB_CONTAINER = new MariaDBContainer<>("mariadb:11.5")
.withDatabaseName("test")
.withUsername("test")
.withPassword("test");
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver
url: jdbc:tc:mariadb:10.11://test
url: jdbc:tc:mariadb:11.5://test
username: test
password: test

Expand Down

0 comments on commit cad92c1

Please sign in to comment.