gpt4 book ai didi

unit-testing - Spring Controller 测试。似乎找不到 MockMvcRequestBuilders

转载 作者:行者123 更新时间:2023-12-04 05:21:24 24 4
gpt4 key购买 nike

我正在尝试按照 this guide 为我的 Spring Controller 编写一些单元和集成测试。和 Spring's documentation for testing MVC controllers

问题是我无法在 mvnrepository 中为以下代码找到适当的包含

 this.mockMvc.perform(get("/foo").accept("application/json"))
.andExpect(status().isOk())
.andExpect(content().mimeType("application/json"));

我找不到 get("/foo) 方法和 .mimeType(..) 的 jar。

然而,在谷歌搜索时,我能够找到上述 get 和 mimeType at here 的来源。 .
那么,我应该从这个 Spring Test 展示项目中复制粘贴这些帮助类吗?还是我在这里遗漏了什么?

最佳答案

看起来包名从 test.web.server 改变了至 test.web.servlet在 spring-test 中,博客文章/文档对于 Spring 4 已经过时了。

关于unit-testing - Spring Controller 测试。似乎找不到 MockMvcRequestBuilders,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21225908/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com