小编Vol*_*myr的帖子

Junit 平台 v.5.8.1 java.lang.NoSuchMethodError 出现错误:org.junit.platform.commons.util.AnnotationUtils.findAnnotation

我遇到了此代码的问题:

@ExtendWith(MockitoExtension.class)
class ApiRestControllerTest {

  private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
  private MockMvc mockMvc;

  @InjectMocks
  private ApiRestController apiRestController;

  @BeforeEach
  void setUp() {
    mockMvc = MockMvcBuilders
        .standaloneSetup(apiRestController)
        .build();
  }

  @Test
  void shouldReturnsVersion() throws Exception {
    mockMvc.perform(get("/api/v1/version"))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(content().json(OBJECT_MAPPER.writeValueAsString(new VersionResponse(VERSION))));
  }
} 
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

@ExtendWith(MockitoExtension.class)
class ApiRestControllerTest {

  private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
  private MockMvc mockMvc;

  @InjectMocks
  private ApiRestController apiRestController;

  @BeforeEach
  void setUp() {
    mockMvc = MockMvcBuilders
        .standaloneSetup(apiRestController)
        .build();
  }

  @Test
  void shouldReturnsVersion() throws Exception {
    mockMvc.perform(get("/api/v1/version")) …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc spring-test junit5

7
推荐指数
1
解决办法
6378
查看次数

标签 统计

java ×1

junit5 ×1

spring-mvc ×1

spring-test ×1