JUnit 기반 단위 테스트에서 사용되는 Assertion Framework이다.

JUnit에서 제공하는 Assertions 클래스에 비교하여 다음과 같은 장점이 있다.

JUnit과 비교

가독성 비교

JUnit

아래는 JUnit으로 작성한 테스트 코드이다.

JUnit의 assert() 메서드는 메서드를 직접 확인하지 않는 이상 actual과 expected 순서가 헷갈린다. 상황에 따라 작성된 메서드만 보아서는 모호할 수 있다.

package com.codestates.basic;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class HelloJunitTest {

    @DisplayName("Hello Junit Test")
    @Test
    public void assertionTest1() {
        String actual = "Hello, JUnit";
        String expected = "Hello, JUnit";

        assertEquals(expected, actual);
    }
}