zoukankan      html  css  js  c++  java
  • Mac OS command line TestNG

    直接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 Filesjbdevstudio4studioplugins*" org.testng.TestNG testng.xml

    I believe the testng.xml file is under C:UsersmeworkspaceMyProject if not please give the full path for testng.xml file

  • 相关阅读:
    web前端之 CSS
    web前端之 HTML标签详细介绍
    web前端之 HTML介绍
    c++之 scanf 接收用户输入内容
    JQ 全选、全不选
    java 除法向上,向下取整
    Java使用占位符拼接字符串
    eclipse远程debug
    阿里 drds 分布式数据库分节点查询
    Mysql 修改字段长度、修改列名、新增列、修改自增主键起始值
  • 原文地址:https://www.cnblogs.com/melody-emma/p/5212769.html
Copyright © 2011-2022 走看看