junit5 3

JUnit5 Assertions

1. assertAll 만약 assertAll을 안쓰면 assertEquals이 실패하면 assertTrue는 실패인지 성공인지 모른다. 따라서 한번에 테스트 결과를 확인하고 싶으면 assertAll로 묶자! → 보통은 여러개 테스트중 하나만 실패해도 다음 테스트를 진행할수 없지만 assertAll은 실패해도 다음 테스트를 진행 할 수 있다.(에러를 한번에 볼수가 있다.) @Test @DisplayName("스터디 만들기") void create_new_study() throws Exception { Study study = new Study(-10); assertAll( () ->assertNotNull(study), () ->assertEquals(StudyStatus.DRAFT, study.getS..

JAVA 2022.12.14

JUnit5 기본 annotation

JUnit5 test에 사용할 수 있는 기본 annotation @Test @BeforeAll / @AfterAll : 모든 테스트 실행 전 혹은 실행 후 딱 한번씩만 실행됨 @BeforeEach / @AfterEach : 각각 테스트들 마다 실행 전 / 실행 후에 매번 실행됨 @Disabled : 여러개의 테스트 메소드중 제외 하고 싶은것에 붙여줌 package me.whiteship.inflearnthejavatest; import org.junit.jupiter.api.*; import static org.junit.jupiter.api.Assertions.*; class StudyTest { // junit5 부터 public 이 안붙어도됨 @Test void create() throws Exce..

JAVA 2022.12.14

testcode 작성 시 description

testcode 작성 시 메소드명만으로는 자세하게 구별할수가 없다. 따라서 설명 및 이름 같은 것을 붙여주어 구분하기 쉽게 한다. junit4 사용 시 : junit4는 설명을 달기 위해서 따로 annotation을 만들어야한다. package me.whiteship.restapi.common; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target(ElementType.METHOD) // 붙일수 있는 target은 메소드!! @Retention(Retentio..

JAVA 2022.07.11