2015-12-28 31 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的,需要的瀏覽器必須出現在其他計算機和它的是什麼,與你的自動化腳本運行的先決條件。他們必須預先安裝