Recent Posts
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- table not found
- terminal
- PersistenceContext
- PytestPluginManager
- tolerated
- Spring Batch
- taint
- vfr video
- JanusGateway
- 자원부족
- 코루틴 컨텍스트
- 코루틴 빌더
- python
- mp4fpsmod
- 개성국밥
- 깡돼후
- 티스토리챌린지
- JanusWebRTCGateway
- k8s #kubernetes #쿠버네티스
- VARCHAR (1)
- JanusWebRTC
- 겨울 부산
- Value too long for column
- 달인막창
- 헥사고날아키텍처 #육각형아키텍처 #유스케이스
- JanusWebRTCServer
- 오블완
- pytest
- preemption #
- kotlin
Archives
너와 나의 스토리
[Spring/java] junit 5에서 static method mocking하기 본문
반응형
- 필요한 dependency
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.7.7'
- Static method
public class StaticMethodFunction {
public static String getBlogUrl(){
return "https://hororolol.tistory.com/";
}
}
- 위의 static method를 호출할 클래스
public class BlogService {
public String getUrl() {
return StaticMethodFunction.getBlogUrl();
}
}
- 우리는 이 BlogService를 테스트할 것이고, 여기서 호출하는 StaticMethodFuntion의 getBlogUrl()을 mocking할 것이다.
- 먼저 mocking하기 전에, 원래는 어떻게 나오는지 보자.


- 원래는 위의 response body처럼 "https://horrolol.tistory.com/"라고 나온다.
- 이제 테스트를 돌려보자.


- mocking한대로 데이터가 리턴되는 것을 볼 수 있다.
반응형