【发布时间】:2021-05-02 04:43:48
【问题描述】:
我有一个 Spring 5.0.7.RELEASE 应用,有一些 WebLayer 测试我的应用中有这个测试:
@RunWith(SpringRunner.class)
@WebAppConfiguration
public class HongoControllerTest {
@Mock
FactureService factureService;
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
ObjectMapper obj = new ObjectMapper();
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
.build();
when(factureService.setLockFilter(any())).thenReturn(Boolean.TRUE);
}
}
但是当我运行测试时,FactureService 没有被模拟
【问题讨论】:
标签: java spring-boot spring-mvc junit mockito