Maven 不运行我的 Appium(Selenium) 测试



我的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 visiblen", 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 visiblen", homeScreen.isHomeScreenVisible());
}
@AfterClass
public static void tearDown() throws Exception {
stopAppium();
} 

问题出在哪里?如何使用命令行运行测试用例?

您可能在POM.xml 中同时具有TestNg和Junit依赖项

根据TestNg的maven surefire插件的文档。您可能需要运行两个提供程序,例如surefirejunit47和surefire-TestNg,并通过设置属性JUnit=false来避免在surefire-ttestng提供程序中运行JUnit测试。

文档参考-章节"运行测试NG和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>

最新更新