SpringBoot2로 Rest api 만들기(9) – Unit Test

This commit is contained in:
kimyonghwa
2019-04-18 15:20:56 +09:00
parent e4d5cf3a77
commit d2a6c9bc81
2 changed files with 10 additions and 9 deletions

View File

@@ -12,8 +12,7 @@ import java.util.Collections;
import java.util.Optional;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@DataJpaTest
@@ -39,8 +38,9 @@ public class UserJpaRepoTest {
// when
Optional<User> user = userJpaRepo.findByUid(uid);
// then
assertTrue(user.isPresent());
assertThat(user.get().getName(), is(name));
assertNotNull(user);// user객체가 null이 아닌지 체크
assertTrue(user.isPresent()); // user객체가 존재여부 true/false 체크
assertEquals(user.get().getName(), name); // user객체의 name과 name변수 값이 같은지 체크
assertThat(user.get().getName(), is(name)); // user객체의 name과 name변수 값이 같은지 체크
}
}