Spring-boot控制器测试的序列化问题

时间:2019-10-28 14:38:54

标签: spring-boot testing junit5 spring-boot-test

我的控制器测试设置如下:

@ExtendWith(SpringExtension.class)
@WebAppConfiguration()
@ContextConfiguration(classes = {MyController.class, MyExceptionHandler.class})
@EnableWebMvc
public class TeilzahlungControllerTest {
    @Autowired
    private MockMvc mockMvc;
    //test the controller
}

我从@SpringBootTest上运行的大型测试中重构了它。因此,现在我的新测试运行速度快了大约100倍,但不再包含“所有豆子”。它显示了反序列化:某些对象不再正确地反序列化,最大的例子是Instant

您可能还会看到我必须“手动”包括我的“全局” Exceptionhandler(MyExceptionHandler.class)。

所以我的问题是:如何确保我的纤薄ApplicationContext包含所需的所有bean,尤其是反序列化的bean?解决办法不是手工解决吗?

非常感谢!

0 个答案:

没有答案