title: Spring boot: How to read resource from classpath in unit test
body: <p>I'm trying to read a file from classpath like this in my unit test:</p>
  
  <pre><code>@Value("classpath:state.json")
  Resource stateFile;
  </code></pre>
  
  <p>I have <code>state.json</code> file in <code>src/test/resources</code> directory.
  When I try to read this file using <code>stateFile.getInputStream()</code>, it doesn't return any contents. What am I doing wrong?</p>
  
  <p>My test class is annotated like this</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  </code></pre>
  
  <p>I can see that the code fails if I try with a incorrect file. So I think its seeing the file in classpath but for some reason not reading contents.</p>