작성
·
292
0
package hello.servlet.domain.member;
import hello.servlet.domain.member.MemberRepository;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
class MemberRepositoryTest {
MemberRepository memberRepository = MemberRepository.getInstance();
@AfterEach
void afterEach() {
memberRepository.clearStore();
}
@Test
void save() {
//given
Member member = new Member("hello", 20);
//when
Member savedMember = memberRepository.save(member);
//then
Member findMember = memberRepository.findById(savedMember.getId());
assertThat(findMember).isEqualTo(savedMember);
}
@Test
void findAll() {
//given
Member member1 = new Member("member1", 20);
Member member2 = new Member("member2", 30);
memberRepository.save(member1);
memberRepository.save(member2);
//when
List<Member> result = memberRepository.findAll();
//Then
assertThat(result.size()).isEqualTo(2);
assertThat(result).contains(member1, member2);
}
}
답변 2
0
0
안녕하세요. 바틀스나인님, 공식 서포터즈 OMG입니다.
코드 문제는 아닌 것 같고 설정 관련 이슈로 보입니다.
아래 링크를 참고해주세요 :)
https://www.inflearn.com/questions/172527
해결이 안될 경우 댓글남겨주세요
감사합니다.