maven 不从命令行检测测试

maven does not detect tests from the command line

我有一个 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 时,没有执行任何测试

问题在这里:PastisControllerTests Test,而不是 Tests,是 Maven 开箱即用地识别它所需的名称组件。否则,您需要 to override the surefire plugin's behavior.