【问题标题】:Maven TestNG project not executing from command promptMaven TestNG 项目未从命令提示符执行
【发布时间】:2018-07-12 10:26:33
【问题描述】:

当我尝试从命令提示符运行项目时,出现主菜单测试用例失败异常。

java -cp C:\Users\eclipse-workspac\CTv_Web_Auto_Check\bin;C:\Users\eclipse-workspace\CTv_Web_Auto_Check\lib* org.testng.TestNG testng.xml

【问题讨论】:

  • 添加你的错误堆栈跟踪
  • @user7294900 当我尝试通过命令提示符运行时,我的项目在 eclipse 中运行没有任何问题
  • 从命令行尝试 mvn clean install
  • 当我尝试运行 mvn clean install 命令时,我该如何解决这个未知的生命周期阶段“mvn”。您必须以 ::[:]: 格式指定有效的生命周期阶段或目标
  • org.apache.maven.pluginsmaven-compiler-plugin3.7.0org.apache.maven.pluginsmaven-surefire-plugin2.22.0依赖>

标签: testng


【解决方案1】:

首先添加你的 pom 文件:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
        </plugin>
    </plugins>
</build>

在依赖部分:

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.7.0</version>
</dependency>

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20.1</version>
</dependency>

尝试在命令行中运行以下命令来运行您的测试:

1.在 maven 项目中运行所有测试类

mvn test 

2。运行单个测试:

mvn -Dtest=TestClassName#testCaseName test

3. runningalltests(在课堂上):

mvn -Dtest=TestClassName test

4. (如果使用 testNg)通过测试套件运行

mvn -Dsurefire.suiteXmlFiles=src/test/java/com/testsuites/testsuitAll.xml test

我认为您应该使用最后一个 (4.) 并在您的项目路径上进行第一次引用。

希望这会有所帮助,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多