Reputation: 1316
I am trying to create test, that takes something from DB and compare values.
I have class and method:
@RunWith(SpringRunner.class)
@SpringBootTest()
@ActiveProfiles("dev")
public class HibernateDataTest {
@Autowired
private UserRepository userRepository;
@Autowired
private ItemRepository itemRepository;
@Test
public void testData() {
User u = userRepository.findByEmail("[email protected]");
Item item = createItem(u);
Item id = itemRepository.save(item);
assert(...);
}
However, this keep complaining:
Could not open ServletContext resource [/application.properties]
I have datasource defined for hibernate, that takes properties from application.properties file.
My structure is:
-app
-src/main/java
-src/main/resources
-src/test/java
-src/test/resources
How can i link the application.properties file in this test class/method?
Thanks for help!
Upvotes: 1
Views: 431
Reputation: 256
Add a properties file named 'application-dev.properties' in the following path:
src/test/resources
This should work
Upvotes: 1