qwerasdfzxc
165
2021-01-26 21:32:59
0
130

jUnit5 @Transactional Rollback동작 안함 질문


테스트 메소드를 수행하는데, @Transactional을 붙였는데도 Rolback이 수행되지않습니다.

혹시 제가 추가적을 살펴봐야 할 것이있을까요??

@BeforeEach
void setUser()
{
SignUpRequestDto signUpRequestDto = commonFactory.userFactory.getSignUpRequestDto();
user = authService.signUp(signUpRequestDto);
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(user.getId(),"", List.of(new SimpleGrantedAuthority(user.getUserRole().toString()))));
}

@Test
@DisplayName("참여 테스트 성공 ")
void successfulJoinTest()
{
ParticipationRequestDto participationRequestDto = commonFactory.participationFactory.getParticipationRequestDto();
ParticipationResponseDto participationResponseDto = assertDoesNotThrow(() -> participationService.joinRoom(participationRequestDto));

assertEquals(participationResponseDto.getParticipationStatus(), ParticipationStatus.ACTIVE);
assertEquals(participationResponseDto.getFloor(),participationRequestDto.getFloor());
assertEquals(participationResponseDto.getField(),participationRequestDto.getField());
assertEquals(participationResponseDto.getRemainSleepNum(),3);
}

@Test
@DisplayName("이미 참여중이라면 참여 실패")
void participationFailedWhenAlreadyParticipate()
{
ParticipationRequestDto participationRequestDto = commonFactory.participationFactory.getParticipationRequestDto();
assertDoesNotThrow(() -> participationService.joinRoom(participationRequestDto));
assertThrows(AlreadyParticipateException.class,() -> participationService.joinRoom(participationRequestDto));
}

롤백이 되지않아, 테스트가 통과하지못하고있는 상황입니다.

0
  • 답변 0

  • 로그인을 하시면 답변을 등록할 수 있습니다.