How can I load test properties from a file like 'application-test.properties'?
The file is stored in the src/test/resources folder. I put the file also in all possible folders as well. When running the test as part of the Maven test run, all works fine. When running the new (single) test from the (IntelliJ) IDE, each time I get same the error message:
Caused by: java.io.FileNotFoundException: class path resource [application-test.properties] cannot be opened because it does not exist
This is the test class:
@RunWith(SpringRunner.class)
@EnableAutoConfiguration
@ComponentScan(basePackages = {"nl.deholtmans.tjm1706.todolist"})
@PropertySource( "application-test.properties")
public class TodoListServiceTest {
@Autowired
TodoListService todoListService;
@Test
public void testBasic() { ... }
It looks that I have to run the test first time from Maven. Why is that?