본문 바로가기

TDD

AssertJ란

1. 개요

AssertJ는 테스트 코드 가독성을 향상시키며 IDE 내에서 사용하기 쉽도록 설계된 Java 라이브러리이다.

 

2. 설정방법

메이븐과 그래이들로 의존성을 추가해서 간단하게 사용할 수 있다.

Maven

<dependency> 
	<groupId>org.assertj</groupId> 
    	<artifactId>assertj-core</artifactId> 
   	<!-- use 2.9.1 for Java 7 projects --> 
   	<version>3.21.0</version> 
   	<scope>test</scope> 
</dependency>

Gradle

For Gradle users (using the Maven Central Repository)

testImplementation("org.assertj:assertj-core:3.21.0")

Or version 2.9.1 for Java 7 projects

testImplementation("org.assertj:assertj-core:2.9.1")

3. 정리

Assertion(주장, 행사)를 통해서 테스트를 제공하는 자바 라이브러리이다.

에러 메세지와 예외처리의 가독성을 높여주며 인텔리제이와 이클립스에서 사용하기 쉽다.

AssertJ는 여러 함수 기능을 제공하며 제공된 왼쪽에서 오른쪽으로 자연스럽게 읽을 수 있다.

공식문서를 참조해서 AssertJ의 여러 함수 기능을 이용해서 가독성 높은 테스트 코드를 만들 수 있다.

 

참조 (https://assertj.github.io/doc/, https://joel-costigliola.github.io/assertj/assertj-core-features-highlight.html#exception-assertion)

 

 

AssertJ - fluent assertions java library

Thanks to all the contributors of this release: Erhard Pointl, Stefano Cordio, Shivakumar Swamy, Iván Aguilar, Alberto Pascual, Gily H, Stefan Bischof, RGalways17, Andrey Kuzmin, Eugene Lesnov, Szymon Linowski, Julian Honnen, Almir James Lucena and Golan

assertj.github.io

 

'TDD' 카테고리의 다른 글

TDD 시작  (0) 2021.05.17
JUnit을 이용한 TDD 생성  (0) 2021.01.31