【问题标题】:How to run testng test cases in UNIX/LINUX environment如何在 UNIX/LINUX 环境下运行 testng 测试用例
【发布时间】:2015-02-08 04:00:22
【问题描述】:

我是自动化测试和 Testng 框架的新手。我正在 java 和 windows 环境中开发我的测试用例。我想在 unix/linux 环境中运行这些开发的测试用例。谁能帮助我一步一步这个过程。非常感谢

@PeterLawrey 我有下面的 pom.xml,我正在尝试在 unix 上执行

    {   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-              instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>ProjTestAutomation</groupId>
      <artifactId>ProjTestAutomation2</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <name>ProjTestAutomation</name>
      <description>ProjTestAutomation</description>
      <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
          <resource>
            <directory>src</directory>
            <excludes>
              <exclude>**/*.java</exclude>
            </excludes>
          </resource>
        </resources>
        <plugins>
          <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
              <source>1.7</source>
              <target>1.7</target>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <configuration>
         <!-- Suite testng xml file to consider for test execution -->
              <suiteXmlFiles>
                <suiteXmlFile>testng.xml</suiteXmlFile>
              </suiteXmlFiles>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <dependencies>
      <dependency>
      <groupId>ProjestAutomation</groupId>
        <artifactId>ProjTestAutomation2</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        </dependency>
      <dependency>
      <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.7</version>
        </dependency>
         <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.0.2</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.0.2</version>
      </dependency>
      </dependencies>
     </project>

    } 

但我遇到了错误 [错误] 无法在项目 MDFsureManager 上执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test):执行目标 org.apache.maven.plugins:maven-surefire 的默认测试-plugin:2.17:test failed: 分叉进程出错 [错误] org.testng.TestNGException: [错误] 在类路径中找不到类:TestCustomerResource

【问题讨论】:

  • 我会从你的构建系统运行测试。你有maven 或ant 吗?在 Maven 中,您将运行 mvn test
  • 是的,您按照 maven 的指南进行设置。然后运行它是微不足道的。
  • 哦..好的,谢谢。我会经历的。如有任何澄清将与您联系。谢谢
  • @PeterLawrey 我有下面的 pom.xml 我正在尝试在 unix {} 上执行

标签: java unix testing testng


【解决方案1】:

正如 Peter Lawrey 所说,使用一些 java 构建系统。比你独立于平台。

可能的选择:

  • Gradle - 非常灵活,使用 Groovy 语言进行配置
  • Maven - XML 声明式配置,大量插件
  • Ivy+Ant

我个人使用独立的 Ant(很痛苦)。比 Maven 好,从那以后再也没有去别处。

如果您想开始使用 Maven,请查看 https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html。这是 XML 如何integrate it with TestNg。

如果您打算进行认真的 Java 编程,则必须熟悉一些构建系统,这会带来更高的生产力。

【讨论】:

  • +1 构建系统将为您运行测试以及更多。设置起来可能会很痛苦,但一旦你完成它就会为你节省很多时间。
猜你喜欢
  • 1970-01-01
  • 2018-09-09
  • 1970-01-01
  • 2018-09-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-21
相关资源
最近更新 更多