这是我的测试文件,我无法从属性文件中插入值
@RunWith(MockitoJUnitRunner.class)
@ContextConfiguration(classes = VersionResourceImplTest.myProp.class)
@TestPropertySource(properties = {"ra.bank.app.version=TestVersion"})
public class VersionResourceImplTest {
@Value("${ra.bank.app.version}")
private String applicationVersion;
@Test
public void testVersion() {
Assert.assertEquals("TestVersion", applicationVersion);
}
@Configuration
public static class myProp{
@Bean
public static PropertySourcesPlaceholderConfigurer propertiesResolver()
{
return new PropertySourcesPlaceholderConfigurer();
}
}
}
获取错误:测试失败:
VersionResourceImplTest.testVersion:36 expected:<TestVersion> but was:<null>
Not able to fetch values from property file