2015-12-28 29 views
0

我有一个TestNG项目,我使用testng.xml文件执行。 如何把我的项目的罐子,并在另一台机器上执行它。 我知道如何通过给仓的路径来执行它在同一台机器上&的lib文件夹,即如何从命令行执行没有主要方法的Testng项目

CD C:\工作区\项目名称java命令 C:\工作区\项目名称\ lib中*; C:\ Workspace \ projectname \ bin org.testng.TestNG testng.xml。

但是,如果我想在另一台机器上做如何做到这一点?

+0

完全相同的方式。最好使用构建脚本将代码和库和资源文件打包到一个JAR中,然后直接在目标机器上执行该脚本。 Google Maven或Gradle获取更多信息。 – xaviert

+0

我已经创建了一个我的项目的zip文件,那么如何使用xml文件执行它 –

+0

您不能使用您的XML文件_execute_该ZIP文件。使用命令行(就像你已经做过的那样)或者使用bash/shell脚本来使用ZIP文件和XML文件调用'java ...'命令。 – xaviert

回答

1

您可以创建一个指向您的testng.xml文件的bash文件。

使用此: Bash file is running fine in windows for testng but it is not working in linux/mac

步骤: -

1. Create a notepad file 
2. Copy -> java -cp ./src/lib/*:./bin org.testng.TestNG testng.xml(use ; instead of : if you are using windows) (./src/lib/* -> All your jars files must present in this location, ./bin -> all your class files must be present here) 
3. save the file. 
4. Rename the file as something.bat 
5. Double click on file if you are using windows or use **bash filename** if using linux or mac 

注: - Java的,需要的浏览器必须出现在其他计算机和它的是什么,与你的自动化脚本运行的先决条件。他们必须预先安装