maven不运行我的appium(selenium)测试

thtygnil  于 2021-06-29  发布在  Java
关注(0)|答案(1)|浏览(469)

我的jdk是 1.8 版本,当然是 2.22.2 ,maven是 3.6.3 . 我正在使用junit和spring注解。
当我试着用 mavn test 命令,我没有错误,我得到成功建立和没有案件运行。
运行testcases.testlogin使用org.apache.maven.surefire.testng.conf配置testng。testng652configurator@7bb11784 测试运行:0,失败:0,错误:0,跳过:0,所用时间:0.808秒
当我使用intellij ui runner运行该类时,案例运行正确。我的类名以 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();
}

问题是什么?如何使用命令行运行测试用例?

b91juud3

b91juud31#

pom.xml中可能同时存在testng和junit依赖项
根据maven surefire plugin for testng的文档,您可能需要运行两个提供程序,例如surefire-junit47和surefire testng,并通过设置属性junit=false避免在surefire testng提供程序中运行junit测试。
documentationref-“运行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>

相关问题