我的JDK是1.8
版本,Surefire是2.22.2
,Maven是3.6.3
。我正在使用junit和spring注释。
当我尝试使用mavn test
命令运行测试时,没有错误,没有成功构建,也没有案例运行。
运行testCases.TestLogin将TestNG配置为:org.apache.maven.surefire.testng.conf.TestNG652Configurator@7bb11784测试运行:0,失败:0,错误:0,跳过:0,经过时间:0.808秒
当我使用IntellIJ UI运行器运行类时,案例可以正确运行。我的班级名称以开头Test*
。这是我的测试代码。
package testCases; import appium.AppiumController; import org.junit.*; import org.springframework.context.annotation.Description; import screens.HomeScreen; import screens.LoginScreen; public class TestLogin extends AppiumController { protected static LoginScreen loginScreen; protected static HomeScreen homeScreen; @BeforeClass public static void setUp() throws Exception { startAppium(); loginScreen = new LoginScreen(driver, wait); homeScreen = new HomeScreen(driver, wait); } @After public void afterEach() { loginScreen.appReset(); } @Test @Description("Verify user can login with valid credentials") public void validLoginTest() throws Exception { loginScreen.login("admin", "admin"); Assert.assertTrue("Home screen is not visible\n", homeScreen.isHomeScreenVisible()); } @Test @Description("Verify user can not login with invalid credentials") public void invalidLoginTest() throws Exception { loginScreen.login("admin1", "admin1"); Assert.assertFalse("Home screen is visible\n", homeScreen.isHomeScreenVisible()); } @AfterClass public static void tearDown() throws Exception { stopAppium(); }
有什么问题,如何使用命令行运行测试用例?
您可能在POM.xml中同时具有TestNg和Junit依赖项
根据用于TestNg的maven-surefire-plugin插件的文档。您可能希望运行两个提供程序,例如surefire-junit47和surefire-testng,并通过设置属性junit = false来避免在surefire-testng提供程序中运行JUnit测试。
文档 参考- “运行TestNG和JUnit测试”部分
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<properties>
<property>
<name>junit</name>
<value>false</value>
</property>
</properties>
<threadCount>1</threadCount>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句