直接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. debug模式总是自动跳到ThreadPoolExecutor

    debug模式下eclipse总是自动跳到ThreadPoolExecutor解决方案 debug模式下eclipse总是自动跳到ThreadPoolExecutor解决方案 在eclipse中点击W ...

  2. Discrete Logging(poj 2417)

    高次同余方程.   BL == N (mod P)求解最小的L. /* A^x=B(mod C) 设x=i*m-j(其中m=ceil(sqrt C)) 并且i∈[1,m],j∈[0,m],以保证x能取 ...

  3. UVa11361 Investigating Div-Sum Property

    数位DP f[位数][自身模k余数][各位数字之和模k余数][当前位是否有上限]=方案数 k<10000,空间不够,如何优化? 不必优化,2^31以内,数字最多只有10位,各位数字之和最多为99 ...

  4. javascript事件捕获机制,dom tree

    $(document,"a").on("click",function(){alert(2);return false;}); $("<a> ...

  5. windows命令行中java和javac、javap使用详解(java编译命令)

    如题,首先我们在桌面,开始->运行->键入cmd 回车,进入windows命令行.进入如图所示的画面: 可知,当前默认目录为C盘Users文件夹下的Administrator文件夹.一般而 ...

  6. 标准C程序设计七---41

    Linux应用             编程深入            语言编程 标准C程序设计七---经典C11程序设计    以下内容为阅读:    <标准C程序设计>(第7版) 作者 ...

  7. 标准C程序设计七---32

    Linux应用             编程深入            语言编程 标准C程序设计七---经典C11程序设计    以下内容为阅读:    <标准C程序设计>(第7版) 作者 ...

  8. poj 3204(最小割--关键割边)

    Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7 ...

  9. LeetCode OJ--Minimum Path Sum **

    https://oj.leetcode.com/problems/minimum-path-sum/ 对一个grid从左上角到右下角的路径,求出路径中和最小的. 受之前思路的影响,就寻思递归,并且记录 ...

  10. Ubuntu 16.04安装Wine版的迅雷+QQ(完美方案,终极解决方法)

    安装前先备份好系统! 继上一篇安装QQ的方法http://www.cnblogs.com/EasonJim/p/7425978.html,这一篇的QQ采用的是Wine模式安装.完美解决消息记录中文乱码 ...