TIL

2021.08.24~25 기록장

Gisungcu 2021. 8. 23. 22:43

ToDo

  • 알고리즘 문제
  • 토이 프로젝트
  • 책 읽기

Done

  • 토이 프로젝트

Weekly goal

  • 책 읽기
  • 7월 회고 쓰기

 

test

 

ThrowableAssert.ThrowingCallable

ThrowingCallable에 예외를 throw 하는 call 메서드가 있다.

 

https://joel-costigliola.github.io/assertj/core-8/api/org/assertj/core/api/ThrowableAssert.ThrowingCallable.html#call--

 

ThrowableAssert.ThrowingCallable (AssertJ fluent assertions 3.12.0 API)

 

joel-costigliola.github.io

 

thenThrownBy

BDD 기반의 예외 체크 방법, 예외가 없으면 에러가 발생

 

https://joel-costigliola.github.io/assertj/core-8/api/org/assertj/core/api/BDDAssertions.html

 

BDDAssertions (AssertJ fluent assertions 3.12.0 API)

Allows to capture and then assert on a Throwable like thenThrownBy(ThrowingCallable) but this method let you set the assertion description the same way you do with as(String, Object...). Example: @Test public void testException() { // if this assertion fai

joel-costigliola.github.io

springBootTest는 일단 콘텍스트는 띄운다. 

 

목 빈은 콘텍스트 안에 있는 것을 목으로 대체해준다는 것인데 굳이 @SpringBootTest까지 써서 저 어노테이션을 써야 하나 의문이다. 그냥 mock(UserService.class)을 사용하면 콘텍스트 안 띄우고 같은 목객체를 얻는 것인데.. 

물론 간편하다는  장점이 있다.

 

그래서 나의 test 코드는 후자로 변경을 했다.

https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.spring-boot-applications

 

Spring Boot Features

Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and Servlet-based web applications. It occurs as part of closing the application context and is performed in the earliest

docs.spring.io

https://meetup.toast.com/posts/124

 

Spring Boot Test : NHN Cloud Meetup

Spring Boot Test

meetup.toast.com