January 2018
Intermediate to advanced
414 pages
10h 29m
English
Spring uses Mockito for mocking, the most widely used Java library for mocking objects in the JVM, and provides an annotation to use it easily with our Spring context. We will modify our CustomerControllerTest class to first add a Mock to our CustomerService bean:
package com.microservices.chapter09import org.junit.Testimport org.junit.runner.RunWithimport org.springframework.beans.factory.annotation.Autowiredimport org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvcimport org.springframework.boot.test.context.SpringBootTestimport org.springframework.boot.test.mock.mockito.MockBeanimport org.springframework.test.context.junit4.SpringRunnerimport org.springframework.test.web.servlet.MockMvcimport ...
Read now
Unlock full access