From the course: Spring Data

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Embedded database for testing

Embedded database for testing - Spring Tutorial

From the course: Spring Data

Embedded database for testing

- [Instructor] Now let's see if we can get those tests to work. I'm in Branch 03_05b, and and I have my tests open. And just to show what happens when I try to run them, they will fail because they're going to try to look for certain data elements that are not present in the postgres database. So what can we do? So we need to go into our test folder and I need to create a folder called resources, similar to the resources folder under main. There's our resources under main, but now we're having one under test. And within main, we're going to take the data.sql file and drop it into the resources folder under test, because this is now, we want this data. And we also want to create a file called application.properties that will be in this test folder, and we want to configure it to interact with H2. So I'm over in this tab, I have the branch 05_03e, and here is the application.properties. I'm just going to copy that whole file contents and paste it into this file. There we go. And now we…

Contents