Values not getting loaded from property file in JUnit
up vote
0
down vote
favorite
This is my test file and I am not able to inject values from property file
@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();
Getting error: Failed tests:
VersionResourceImplTest.testVersion:36 expected:<TestVersion> but was:<null>
Not able to fetch values from property file
junit junit4
New contributor
add a comment |
up vote
0
down vote
favorite
This is my test file and I am not able to inject values from property file
@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();
Getting error: Failed tests:
VersionResourceImplTest.testVersion:36 expected:<TestVersion> but was:<null>
Not able to fetch values from property file
junit junit4
New contributor
Your test doesn't use RunWith(SpringRunner.class), so all the Spring annotations are simply ignored.
– JB Nizet
Nov 10 at 12:12
yeah...it worked for me ...thanks a LOT :)
– Supriya
Nov 10 at 12:17
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This is my test file and I am not able to inject values from property file
@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();
Getting error: Failed tests:
VersionResourceImplTest.testVersion:36 expected:<TestVersion> but was:<null>
Not able to fetch values from property file
junit junit4
New contributor
This is my test file and I am not able to inject values from property file
@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();
Getting error: Failed tests:
VersionResourceImplTest.testVersion:36 expected:<TestVersion> but was:<null>
Not able to fetch values from property file
junit junit4
junit junit4
New contributor
New contributor
edited Nov 10 at 11:18
user6910411
31.5k76592
31.5k76592
New contributor
asked Nov 10 at 9:52
Supriya
11
11
New contributor
New contributor
Your test doesn't use RunWith(SpringRunner.class), so all the Spring annotations are simply ignored.
– JB Nizet
Nov 10 at 12:12
yeah...it worked for me ...thanks a LOT :)
– Supriya
Nov 10 at 12:17
add a comment |
Your test doesn't use RunWith(SpringRunner.class), so all the Spring annotations are simply ignored.
– JB Nizet
Nov 10 at 12:12
yeah...it worked for me ...thanks a LOT :)
– Supriya
Nov 10 at 12:17
Your test doesn't use RunWith(SpringRunner.class), so all the Spring annotations are simply ignored.
– JB Nizet
Nov 10 at 12:12
Your test doesn't use RunWith(SpringRunner.class), so all the Spring annotations are simply ignored.
– JB Nizet
Nov 10 at 12:12
yeah...it worked for me ...thanks a LOT :)
– Supriya
Nov 10 at 12:17
yeah...it worked for me ...thanks a LOT :)
– Supriya
Nov 10 at 12:17
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Supriya is a new contributor. Be nice, and check out our Code of Conduct.
draft saved
draft discarded
Supriya is a new contributor. Be nice, and check out our Code of Conduct.
Supriya is a new contributor. Be nice, and check out our Code of Conduct.
Supriya is a new contributor. Be nice, and check out our Code of Conduct.
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237801%2fvalues-not-getting-loaded-from-property-file-in-junit%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Your test doesn't use RunWith(SpringRunner.class), so all the Spring annotations are simply ignored.
– JB Nizet
Nov 10 at 12:12
yeah...it worked for me ...thanks a LOT :)
– Supriya
Nov 10 at 12:17