![](/img/trans.png)
[英]Is there any way to run the junit / TestNG test cases in test environment?
[英]How to run testng test cases in UNIX/LINUX environment
我是自動化測試和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>
}
但我得到以下錯誤[ERROR]無法在項目MDFSureManager上執行目標org.apache.maven.plugins:maven-surefire-plugin:2.17:test(默認測試):目標org.apache.maven的執行默認測試.plugins:maven-surefire-plugin:2.17:test失敗:分叉的進程中發生錯誤[ERROR] org.testng.TestNGException:[ERROR]在類路徑中找不到類:TestCustomerResource
正如Peter Lawrey所提到的,請使用一些Java構建系統。 比您獨立於平台。
可能的選擇:
我個人使用了獨立的Ant(感到很痛苦)。 比Maven還沒去過其他地方。
如果要開始使用Maven,請查看https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html 。 這是XML如何將其與TestNg集成 。
如果您打算進行認真的Java編程,那么必須熟悉一些構建系統,並且可以通過提高生產力來獲得回報。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.