I created one folder src/test/resources and added one file Test.json and trying to access in junit test like this
@RunWith(SpringRunner.class)
@WebMvcTest(value = ReadController.class, secure = false)
public class ReadControllerTest {
@Value("${classpath:Test.json}")
Resource testFile;
@Test
public void test() throws Exception{
File file = testFile.getFile();
System.out.println(file.exists());
}
}
When I run this unit test, it tries to find file in classpath but file is not present there. How to add this file in classpath?