@TestPropertySource using to read property file entries while writing junit testcases, but in my case using this annotation not working

40 Views Asked by At

I am writing JUnit test cases for a controller class. In my controller class I am using a couple of entries reading from a property file.

I used the @InjectMock annotation to mock the controller class and I am using the @TestPropertySource annotation to read the test properties but unfortunately I'm getting null values for property entries.

Please help how to read property values in my test class.

This is my sample test class:

    @Runwith(MockitoJunitRunner.class)
    @TestPropertySource(locations={"classpath: application-test.properties"})
    public class Controller test {
    
        @InjectMocks
        private Controller controller;
    
    }
0

There are 0 best solutions below