JAVA/test code
[TEST]ReflectionTestUtils
닉의네임
2023. 3. 14. 16:10
반응형
ReflectionTestUtils??
ReflectionTestUtils 는 Spring Test Context 프레임워크의 일부입니다. 이는 단위에서 사용되는 리플렉션 기반 유틸리티 메서드의 모음이며, 비공개 필드를 설정하고 비공개 메서드를 호출하고 의존성을 주입하기 위한 통합 테스트 시나리오
import org.springframework.test.util.ReflectionTestUtils;
@Test
public void test_weightLogic_getPriceWeight(){
assertEquals(
ReflectionTestUtils.invokeMethod( new Weight(), "getPriceWeight", 5600L), (Double)1.49);
}
@Test
public void test_weightLogic_getStoreTypeWeight_hyper_nor(){
assertEquals(
ReflectionTestUtils.invokeMethod( new Weight(), "getStoreTypeWeight", StoreType.HYPER.name(), StoreKind.NOR.name()), (Double)1.0);
}
반응형