To enable testing, add the following dependency in the pom.xml file:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
To test the RestaurantController, the following files have been added:
- The RestaurantControllerIntegrationTests class, which uses the
@SpringApplicationConfiguration annotation to pick the same configuration that Spring Boot uses:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = RestaurantApp.class)
public class RestaurantControllerIntegrationTests extends
AbstractRestaurantControllerTests {
}
- An abstract class to write our tests:
public abstract class AbstractRestaurantControllerTests {
protected static final String RESTAURANT = "1";
protected static final String...