title: How to load values from custom properties file for junit testing using Mockito?
body: <p>I have written this test class to check a service. This is in folder test/java/example/demp/Test.java</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  @TestPropertySource("classpath:conn.properties")
  
  public class DisplayServiceTest {
  
  
  @Value("${id}")
  private String value; 
  
  
  @Mock
  private DisplayRepository DisplayReps;
  
  @InjectMocks
  private DisplayService DisplayService;
  
  @Test
  public void whenFindAll_thenReturnProductList() {
  
  Menu m = new Menu()
  m.setId(value); //when I print value its showing 0
  
  List&lt;Display&gt; expectedDisplay = Arrays.asList(m);
  doReturn(expectedDisplay).when(DisplayReps).findAll();
  List&lt;Display&gt; actualDisplay = DisplayService.findAll();
  assertThat(actualDisplay).isEqualTo(expectedDisplay);
  }
  </code></pre>
  
  <p>My properties file
  This is in folder test/resources/conn.properties</p>
  
  <pre><code>id=2
  </code></pre>
  
  <p>What is the right way to set properties from custom properties file? Cause its not loading values ?</p>