I have configuration class:
@ConfigurationProperties(prefix = "myConfig")
public class MyConfig {
protected String config;
}
My service uses this config class and I'm trying to test it with Mockito:
@RunWith(MockitoJUnitRunner.class)
public class myTest {
@InjectMocks
private MyService myService;
@Mock
private MyConfig myConfig;
@Test
public void myTest1() {
myService.getInfo("a");
}
}
myTest
fails since the config class is mocked, thus has null values. What is the right way to test configuration class with Mockito?
Aucun commentaire:
Enregistrer un commentaire