如何在没有main方法的情况下从命令行执行Testng项目 [英] How to execute Testng project without main method from command line

查看:2531
本文介绍了如何在没有main方法的情况下从命令行执行Testng项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TestNG项目,我使用testng.xml文件来执行。
如何拿一个jar我的项目,并在另一台机器上执行。
我知道如何在同一台机器上通过给出bin& lib文件夹

I have a TestNG project where I use testng.xml file to execute. How to take a jar of my project and execute it on another machine. I know how to execute it on the same machine by giving path of bin & lib folders i.e


cd C:\Workspace \projectname java -cp
C:\Workspace\projectname\\ \\ lib *; C:\Workspace\projectname\bin
org.testng.TestNG testng.xml。

cd C:\Workspace\projectname java -cp C:\Workspace\projectname\lib*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml.

但是如果我想在另一台机器上做这个?

But if i want to do on another machine how to do this?

推荐答案

您可以创建一个bash文件, testng.xml文件。

You can create a bash file which points to your testng.xml file.

使用:

步骤: -

 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,require浏览器必须存在于其他计算机中,它是与自动化脚本运行无关的先决条件。它们必须预先安装

Note: - Java, require browsers must be present in other computer and it's a prerequisite which is nothing to do with your automation script run. they must be pre-installed

这篇关于如何在没有main方法的情况下从命令行执行Testng项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆