인생을 코딩하다.

Junit4 -> Junit5 (목적(쓰임새)은 같지만 4 -> 5 로직 비교) 본문

Spring

Junit4 -> Junit5 (목적(쓰임새)은 같지만 4 -> 5 로직 비교)

Hyung1 2020. 11. 30. 20:12
728x90
반응형

============ 기준으로 위 4, 아래 5

content().string(containsString()) // Junit4
====================================================================
content().string(org.hamcrest.Matchers.containsString()))) // Junit5
assertThat(skhu.getId(), is());       // import org.hamcrest.core.Is.is;
==================================================================================================
assertThat(skhu.getId()).isEqualTo(); // import static org.assertj.core.api.Assertions.assertThat;

 

@BeforeAll -> BeforeClass / @Before -> @BeforeEach

 

@Test(exampleNotFoundExcepiton.class) // Junit4
public void getExampleWithNotExisted() {
	exampleSerivce.getExample(404L)
    
=======================================================================================
@test
public void getExampleWithNotExisted() { // Junit5
	exampleService.getExample(404L);
	
    assertThrow(ExampleNotFoundException.cass, () -> exampleService.getExample(404));

 

...작성중

728x90
반응형
Comments