【问题标题】:how to execute testng in mac os command terminal如何在 mac os 命令终端中执行 testng
【发布时间】:2018-08-15 17:45:17
【问题描述】:

当我尝试从 Windows 机器执行我的 testng 时,我能够毫无问题地执行 mky 测试。

我正在使用命令:java -cp bin;jarslib/* org.testng.TestNG testng.xml 我在项目文件夹中的 jarslib 文件夹中拥有我所有的 jars。

但是当我从 MAC OS 执行时,我收到以下错误:

Usage: java [-options] class [args...]
       (to execute a class)

或 java [-options] -jar jarfile [args...] (执行一个jar文件) 其中选项包括: -d32 使用 32 位数据模型(如果可用) -d64 使用 64 位数据模型(如果可用) -server 选择“服务器”VM 默认虚拟机是服务器, 因为您在服务器级机器上运行。

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
              A : separated list of directories, JAR archives,
              and ZIP archives to search for class files.
-D<name>=<value>
              set a system property
-verbose:[class|gc|jni]
              enable verbose output
-version      print product version and exit
-version:<value>
              Warning: this feature is deprecated and will be removed
              in a future release.
              require the specified version to run
-showversion  print product version and continue
-jre-restrict-search | -no-jre-restrict-search
              Warning: this feature is deprecated and will be removed
              in a future release.
              include/exclude user private JREs in the version search
-? -help      print this help message
-X            print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
              enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
              disable assertions with specified granularity
-esa | -enablesystemassertions
              enable system assertions
-dsa | -disablesystemassertions
              disable system assertions
-agentlib:<libname>[=<options>]
              load native agent library <libname>, e.g. -agentlib:hprof
              see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
              load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
              load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
              show splash screen with specified image

请参阅http://www.oracle.com/technetwork/java/javase/documentation/index.html 了解更多详情。 jarslib/bsh-2.0b6.jar:第 1 行:PK:找不到命令 jarslib/bsh-2.0b6.jar:第 2 行: ?EH: 找不到命令 jarslib/bsh-2.0b6.jar:第 3 行:找不到命令 jarslib/bsh-2.0b6.jar:第 4 行:意外标记附近的语法错误 )' jarslib/bsh-2.0b6.jar: line 4:?EH?Je?^META-INF/MANIFEST.MFm??N1 ??Hy?eH.9t?D{C???.)M??ҩoO'

【问题讨论】:

    标签: java testng


    【解决方案1】:

    由于类路径中的分号,shell 将您的命令解释为 2 个命令。改为使用冒号 (:) 作为分隔符:

    java -cp bin:jarslib/* org.testng.TestNG testng.xml
    

    【讨论】:

    • 可能值得明确指出,;(分号)是 Windows 上的类路径分隔符,而在(大多数)其他平台(包括 macOS)上是 :(冒号)。跨度>
    • 我得到这样的输出:================================= ============= 套件运行总数:1,失败:0,跳过:1 配置失败:1,跳过:2 =============== ================================= 但是执行没有发生。
    猜你喜欢
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 2011-06-11
    • 2023-03-27
    • 2022-01-06
    • 1970-01-01
    相关资源
    最近更新 更多