英文:
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
时,没有执行任何测试。
英文:
I have a Spring MVC project (an application framework and inversion of control container for the Java platform) with this test:
@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());
}
..
}
but when I run mvn test
from the command line, no test is executed
答案1
得分: 0
问题在这里:PastisControllerTests
。Test
,而不是Tests
,是您需要的名称组件,以便Maven可以直接识别它。否则,您需要覆盖surefire插件的行为。
英文:
The problem is here: PastisControllerTests
Test
, not Tests
, is the name component you need for Maven to recognize it out of the box. Otherwise, you need to override the surefire plugin's behavior.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论