July 2017
Intermediate to advanced
414 pages
11h 18m
English
There are multiple ways to test REST/JSON Spring Boot microservices. The easiest way is to use a web browser or a curl command pointing to the URL, like this:
curl localhost:8080
There are number of tools available for testing RESTful services such as Postman, Advanced Rest Client, SOAP UI, Paw, and more.
In this example, for testing the service, the default test class generated by Spring Boot will be used. Adding a new test case to ApplicatonTests.java results in this:
@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class ApplicationTests { @Autowired private TestRestTemplate restTemplate; @Test public void testSpringBootApp() throws JsonProcessingException, ...Read now
Unlock full access