분류 전체보기 1341

Ch01. JUnit5 - JUnit5 테스트 반복하기

JUnit5 테스트 반복하기 @RepeatedTest 반복되는 테스트를 실행할 때, 사용한다. parameter로 들어오는 RepotitionInfo에는 총 횟수, 현재 idx 정보가 들어있다. 테스트의 이름을 다양한 방식으로 보여줄 수 있는데 {dispalyName}과 같은 속성을 사용이 가능하다. @ParameterizedTest 파라미터로 받는 message에 현재 idx에 해당되는 message가 들어 있다. JUnit5 테스트 반복하기 2부 https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests JUnit 5 User Guide Although the JUnit Jupiter programming mo..

Ch01. JUnit5 - JUnit5 Assertion

마지막 매개변수로 Supplier 타입의 인스턴스를 람다 형태로 제공할 수 있다 복잡한 메시지 생성해야 하는 경우 사용하면 실패한 경우에만 해당 메시지를 만들게 할 수 있다 람다식 같은 경우 실패했을때만 실행해준다. 여러 테스트를 한 번에 테스트하여 어떤 것들이 성공, 실패하였는지 한 번에 알 수가 있다. 단, assertTimeoutPreemptively를 사용하게 된다면 뒤에 로직이 끝날 때까지 기다리는 것이 아니라 바로 종료하여 주지만, 스레드와 상관없는 코드를 동작시킬 때만 사용하여야 한다.

Ch01. JUnit5 - JUnit5 테스트 이름 표시하기

https://junit.org/junit5/docs/current/user-guide/#writing-tests-display-names JUnit 5 User Guide Although the JUnit Jupiter programming model and extension model will not support JUnit 4 features such as Rules and Runners natively, it is not expected that source code maintainers will need to update all of their existing tests, test extensions, and cus junit.org 기본적으로 테스트 이름은 언더바를 활용하여 표기한다 @Disp..

Ch01. JUnit5 - JUnit5 시작하기

SpringBoot 2.2 이상부터는 SpringBootStarter가 제공하는 JUnit 버전이 변경되었다(4 -> 5) JUnit5부터는 public 제약이 사라졌다 기본 애노테이션 @Test @BeforeAll / @AfterAll private X, default O, return Type 존재 X 테스트를 실행할 때 딱 1번만 실행된다. @BeforeEach / @AfterEach 테스트가 실행될 때마다 실행된다. @Disabled 실행하고 싶은 Test가 존재할 경우 실행한다. class StudyTest { @Test void create(){ //JUNIT5 부터는 public 제약이 사라졋다 Study study = new Study(); assertNotNull(study); Syste..

Ch01. JUnit5 - JUnit 5 소개

자바 개발자가 가장 많이 사용하는 테스팅 프레임워크 자바 8 이상을 필요로 함 https://junit.org/junit5/docs/current/user-guide/ JUnit 5 User Guide Although the JUnit Jupiter programming model and extension model will not support JUnit 4 features such as Rules and Runners natively, it is not expected that source code maintainers will need to update all of their existing tests, test extensions, and cus junit.org

Ch06. 스프링 데이터 JPA가 제공하는 Querydsl 기능 - Querydsl 지원 클래스 직접 만들기

스프링 데이터가 제공하는 QuerydslRepositorySupport 가 지닌 한계를 극복하기 위해 직접 Querydsl 지원 클래스를 만들어보자. 장점 스프링 데이터가 제공하는 페이징을 편리하게 변환 페이징과 카운트 쿼리 분리 가능 스프링 데이터 Sort 지원 select() , selectFrom()으로 시작 가능 EntityManager , QueryFactory 제공 QuerydslRepositorySupport /** * Querydsl 4.x 버전에 맞춘 Querydsl 지원 라이브러리 * * @author Younghan Kim * @see org.springframework.data.jpa.repository.support.QuerydslRepositorySupport */ @Reposi..

실전! Querydsl 2022.01.02

Ch06. 스프링 데이터 JPA가 제공하는 Querydsl 기능 - Repository 지원(QuerydslRepositorySupport)

장점 getQuerydsl().applyPagination() 스프링 데이터가 제공하는 페이징을 Querydsl로 편리하게 변환 가능(단! Sort는 오류 발생) from()으로 시작 가능(최근에는 QueryFactory를 사용해서 select()로 시작하는 것이 더 명시적) EntityManager 제공 한계 Querydsl 3.x 버전을 대상으로 만듬 Querydsl 4.x에 나온 JPAQueryFactory로 시작할 수 없음 select로 시작할 수 없음 (from으로 시작해야 함) QueryFactory를 제공하지 않음 스프링 데이터 Sort 기능이 정상 동작하지 않음

실전! Querydsl 2022.01.02