더 자바, 애플리케이션을 테스트하는 다양한 방법

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

webmaster 2022. 1. 3. 16:32
728x90

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

  • 기본적으로 테스트 이름은 언더바를 활용하여 표기한다
  • @DisplayNameGeneration 
    •  
      테스트 이름을 클래스 별로 전략을 정할 수 있다.
       
    • Method와 Class 레퍼런스를 사용해서 테스트 이름을 표기하는 방법 설정. 
    • 기본 구현체로 ReplaceUnderscores 제공
  • @DisplayName
    • 메소드 단위로 테스트 명을 지정할 수 있다.
    • 어떤 테스트인지 테스트 이름을 보다 쉽게 표현할 수 있는 방법을 제공하는 애노테이션. 
    • @DisplayNameGeneration 보다 우선순위가 높다.
728x90