작성
·
893
23
제가 실습중인 환경은 SpringBoot 2.3.1.RELEASE여서
error: cannot find symbol
위 오류가 발생했는데, 코드 수정해서 해결했습니다. 참고하시면 도움될것같습니다.
package jpabook.jpashop.member;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
public class MemberRepositoryTest
{
@Autowired
MemberRepository memberRepository;
@Test
@Transactional
// @Rollback(false) 테스트 종료 후 데이터를 롤배하지 않고 그대로 남겨두는 옵션
public void testMember() throws Exception
{
//given
Member member = new Member();
member.setUsername("1hoon");
//when
Long savedId = memberRepository.save(member);
Member findMember = memberRepository.find(savedId);
//then
assertEquals(findMember.getId(), member.getId());
assertEquals(findMember.getUsername(), member.getUsername());
assertEquals(findMember, member);
}
}
RunWith를 생략할 수 있습니다 🙂