org.powermock.reflect.internal.WhiteboxImpl对方法java.lang.Object.clone()的非法反射访问>> [

问题描述 投票:0回答:1
我想使用此JUnit测试来测试私有方法:

@RunWith(SpringRunner.class) @SpringBootTest(classes = ReportingProcessor.class) public class ReportingTest { @Autowired ReportingProcessor reportingProcessor; @Test public void reportingTest() throws Exception { ContextRefreshedEvent contextRefreshedEvent = PowerMockito.mock(ContextRefreshedEvent.class); Whitebox.invokeMethod(reportingProcessor, "collectEnvironmentData", contextRefreshedEvent); } }

但是我得到了WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.powermock.reflect.internal.WhiteboxImpl (file:/C:/Users/Mainuser/.m2/repository/org/powermock/powermock-reflect/2.0.2/powermock-reflect-2.0.2.jar) to method java.lang.Object.clone()
WARNING: Please consider reporting this to the maintainers of org.powermock.reflect.internal.WhiteboxImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

有什么办法解决这个问题?

我想使用此JUnit测试来测试私有方法:@RunWith(SpringRunner.class)@SpringBootTest(classes = ReportingProcessor.class)公共类ReportingTest {@Autowired ...

java spring spring-boot mocking powermock
1个回答
0
投票
已经有一些疑问:
© www.soinside.com 2019 - 2024. All rights reserved.