You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-4Lines changed: 34 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -267,10 +267,40 @@ The JSON representation of an IOU that you'll get in responses or provide in the
267
267
### Exercise 3
268
268
269
269
1. Create an `ious` package inside the `rest-api/src/test/java/com/cbfacademy/springbootexercise` package
270
-
2. Download the [test suite](https://gist.github.com/cbfacademy-admin/be990e8da45fca196513f35f86ed3f52) and copy to the test ious package as IOUControllerTest.java
271
-
3. Run the tests with `./mvnw --projects rest-api clean test`
272
-
4. Examine the results. Do any tests fail? If so, what reasons are given? Modify your code so all tests pass
273
-
5. Commit your changes
270
+
2. Download the [test suite](https://gist.github.com/cbfacademy-admin/be990e8da45fca196513f35f86ed3f52) and copy to the test `ious` package as `IOUControllerTest.java`
271
+
3.**Configure H2 database for testing**: Add the H2 database dependency to your `rest-api/pom.xml` file. Insert this dependency in the `<dependencies>` section:
272
+
273
+
```xml
274
+
<dependency>
275
+
<groupId>com.h2database</groupId>
276
+
<artifactId>h2</artifactId>
277
+
<scope>test</scope>
278
+
</dependency>
279
+
```
280
+
281
+
4.**Create test configuration**: Create a new directory `rest-api/src/test/resources` and add an `application.properties` file with the following content:
5. Run the tests with `./mvnw --projects rest-api clean test`
300
+
6. Examine the results. Do any tests fail? If so, what reasons are given? Modify your code so all tests pass
301
+
7. Commit your changes
302
+
303
+
> :bulb:**Note:** The H2 configuration ensures tests use an in-memory database for speed and isolation, while your production application continues to use MySQL. The `create-drop` setting means the database schema is recreated for each test run, ensuring clean test conditions.
0 commit comments