0

我有一个带有此测试的 Spring MVC 项目(Java 平台的应用程序框架和控制容器反转):

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(locations = {
        "classpath:servlet.xml"
})
public class PastisControllerTests {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {

        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
    }

    @Test
    public void should_WhenParams_OK() throws Exception {

        mockMvc.perform(get("/user/2")
                .param("date", "01122020")
                .param("organisationId", "9")
                .contentType(APPLICATION_JSON))
                .andExpect(status().isOk());
    }
..
}

但是当我从命令行运行时mvn test,没有执行任何测试

4

1 回答 1

0

问题出在这里:PastisControllerTests Test,不是Tests,是 Maven 开箱即用地识别它所需的名称组件。否则,您需要覆盖 surefire 插件的行为

于 2020-10-09T13:43:51.790 回答