直接eclipse执行.xml文件可以正确执行

在mac下执行却总报错:

[TestNG] [Error]

Cannot find class in classpath

最后解决办法,classpath格式错误,正确执行的格式:

先cd 到工程目录,

java -cp "lib/testng-6.9.10.jar:bin:lib/:target/test-classes/"   -Djava.ext.dirs=lib  org.testng.TestNG testSuits/testSuitExample_android.xml

lib  bin  target都是工程下的文件夹,

其中.class文件在target/test-classes/下,lib下是一些引用的jar包,待执行的文件testSuitExample_android.xml在testSuits目录下

mac下用:分隔;windows下用;分隔

详细的如何下dos prompt下执行TestNG见下面链接:

http://stackoverflow.com/questions/11896791/how-to-run-testng-from-dos-prompt

You need to have the testng.jar under classpath.

try C:\projectfred> java -cp "path-tojar/testng.jar:path_to_yourtest_classes" org.testng.TestNG testng.xml

Update:

Under linux I ran this command and it would be some thing similar on Windows either

test/bin# java -cp ".:../lib/*" org.testng.TestNG testng.xml

Directory structure:

/bin - All my test packages are under bin including testng.xml
/src - All source files are under src
/lib - All libraries required for the execution of tests are under this.

Once I compile all sources they go under bin directory. So, in the classpath I need to specify contents of bin directory and all the libraries like testng.xml, loggers etc over here. Also copy testng.xml to bin folder if you dont want to specify the full path where the testng.xml is available.

 /bin
-- testng.xml
-- testclasses
-- Properties files if any.
/lib
-- testng.jar
-- log4j.jar

Update:

Go to the folder MyProject and type run the java command like the way shown below:-

java -cp ".: C:\Program Files\jbdevstudio4\studio\plugins\*" org.testng.TestNG testng.xml

I believe the testng.xml file is under C:\Users\me\workspace\MyProject if not please give the full path for testng.xml file

Mac OS command line TestNG - “Cannot find class in classpath” error的更多相关文章

  1. Awesome Mac OS Command Line 中文翻译

    awesome-macos-command-line 收集了很多有趣的 Mac 终端命令. 看了一遍后,发现帮助很大. 见识许多没有使用过的命令,加深了对 Mac 的认识. 所以翻译成了中文,共享给其 ...

  2. Mac安装Command Line Tools

    从App Store上下载的Xcode,默认是不会安装Command Line Tools的,Command Line Tools是在Xcode中的一款工具,可以在命令行中运行C程序. 在终端中输入命 ...

  3. How To Fix – Mcrypt PHP extension required in Laravel on Mac OS X (No MAMP)

    Laravel PHP web framework requires certain libraries to function properly. One of these libraries is ...

  4. stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

    错误提示: (1). stderr: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer direc ...

  5. Enable rsh on MAC OS with command line

    1. Enable rsh on macos. 1). os version (10.0) Enabling the "Allow remote login" option tur ...

  6. Xcode Command Line Tools for Mac OS X 10.9 Mavericks

    by Daniel Kehoe Last updated 28 December 2013 How to install Apple Xcode Command Line Tools for Mac ...

  7. MAC OS 如何安装命令行工具:Command Line Tools

    打开终端输入:xcode-select --install 回车 安装好了测试结果:gcc -v 显示如下: xcode-select: note: install requested for com ...

  8. Jenkins参数化构建(一)之 Maven Command Line传递TestNG构建参数

    1. Maven使用 -D参数名称 将参数传递至所运行项目 Maven指定TestNg.xml文件 clean test -DsuiteXmlFile=src/main/resources/testn ...

  9. 怎样安装Command Line Tools in OS x Mavericks&Yosemite(Without xcode)--转载

    How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) Mac users who pre ...

随机推荐

  1. 关闭webkit浏览器的自动完成,修正,大写

    关闭input自动完成<input name="q" type="text" autocomplete="off"/>关闭整个表 ...

  2. LineageOS源码定制手机系统

    LineageOS源码定制手机系统 导语: 现在市场的手机基本就两种:  苹果机和android机. 今天我们不谈苹果机, 对小编我来讲,那是个奢侈品, android是我的最爱.对于一般androi ...

  3. bzoj1433 [ZJOI2009]假期的宿舍 最大流

    [ZJOI2009]假期的宿舍 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 3429  Solved: 1459[Submit][Status][D ...

  4. inux下rz、sz的简单安装

    工具/原料 在xshell或者SecureCRT这样的ssh登录软件里, 通过在Linux界面里输入rz/sz命令来上传/下载文件. 对于RHEL5, rz/sz默认没有安装所以需要手工安装. sz: ...

  5. HibernateException: No Hibernate Session bound to thread

    解决No Hibernate Session bound to thread 背景交代 在使用this.getHibernateTemplate().getSessionFactory().getCu ...

  6. web实时长图实践--摘抄

    背景简介 全民K歌专辑发布新玩法,传统宣传专辑战绩的流程,从获取数据,到制作海报,到传播,周期长运营成本高,如何快速分享战绩进行荣誉感的传播成为一个亟待解决的问题. 产品:能不能在专辑大事件触发时,自 ...

  7. Linux 之 服务以及进程

    服务以及进程 参考教程:[千峰教育] 命令: vmstat: 结果: procs -----------memory---------- ---swap-- -----io---- --system- ...

  8. AC日记——[SCOI2010]幸运数字 bzoj 1853

    1853: [Scoi2010]幸运数字 Time Limit: 2 Sec  Memory Limit: 64 MBSubmit: 2405  Solved: 887[Submit][Status] ...

  9. python 之 线程池实现并发

    使用线程池实现高IO并发 模块:ThreadPoolExecutor, as_completed 测试代码如下: #!/opt/python3/bin/python3 from concurrent. ...

  10. Leetcode总结之Union Find

    package UnionFind; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; p ...