인프런 커뮤니티 질문&답변

1103_김민서님의 프로필 이미지

작성한 질문수

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

스프링 통합 테스트

MemberServiceIntegrationTest 오류

작성

·

476

·

수정됨

0


[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예/아니오) 예
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)예
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)예

[질문 내용]


package hello.hellospring.service;

import hello.hellospring.domain.Member;
import hello.hellospring.repository.MemberRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import org.springframework.transaction.annotation.Transactional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

@SpringBootTest
@Transactional
class MemberServiceIntegrationTest {

@Autowired MemberService memberService;
@Autowired MemberRepository memberRepository;

@Test
public void 회원가입() throws Exception {

//Given
Member member = new Member();
member.setName("hello");

//When
Long saveId = memberService.join(member);

//Then
Member findMember = memberRepository.findById(saveId).get();
assertEquals(member.getName(), findMember.getName());
}

@Test
public void 중복_회원_예외() throws Exception {

//Given
Member member1 = new Member();
member1.setName("spring");

Member member2 = new Member();
member2.setName("spring");

//When
memberService.join(member1);
IllegalStateException e = assertThrows(IllegalStateException.class,
() -> memberService.join(member2)); //예외가 발생해야 한다.

assertThat(e.getMessage()).isEqualTo("이미 존재하는 회원입니다.");
}
}

 

이렇게 넣었는데 오류가 납니다. 오류 메세지는 이거

WARNING: A Java agent has been loaded dynamically (C:\Users\halia\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy-agent\1.14.10\90ed94ac044ea8953b224304c762316e91fd6b31\byte-buddy-agent-1.14.10.jar)

WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning

WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information

WARNING: Dynamic loading of agents will be disallowed by default in a future release

Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

입니다 ,,

답변 1

0

안녕하세요. 1103_김민서님, 공식 서포터즈 y2gcoder입니다.

다음 링크(클릭)을 참고해주십쇼!

감사합니다.