작성
·
237
0
package service;
import domain.Member;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
class MemberServiceTest {
MemberService memberService = new MemberService();
@Test
void 회원가입() {
//given
Member member = new Member();
member.setName("hello");
//when
Long saveId = memberService.join(member);
//then
Member findMember = memberService.findOne(saveId).get();
Assertions.assertThat(member.getName()).isEqualTo(findMember.getName());
}
@Test
public void 중복_회원_예외() {
// given
Member member1 = new Member();
member1.setName("spring");
Member member2 = new Member();
member2.setName("spring");
// when
memberService.join(member1);
assertThrows // 이부분은 선언도 안돼요 ㅠㅠ
// try {
// memberService.join(member2);
// fail();
// }catch(IllegalStateException e) {
// Assertions.assertThat(e.getMessage()).isEqualTo("이미 존재하는 회원입니다.");
// }
// then
}
@Test
void findMembers() {
}
@Test
void findOne() {
}
}
답변 1
0
안녕하세요. 허재영님, 공식 서포터즈 OMG입니다.
assertThat()은 아래를 참고하시되 정확히 작성해주세요.
아래의 링크를 참고하여 AssertThrows를 적용하여 보세요.
https://www.inflearn.com/questions/259576
감사합니다.