• Ant学习-002-ant 执行 TestNG 测试用例时 [testng] java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException 解决方案


    上篇文章中概述了 Ant windows 环境的基本配置,此文讲述在初次使用的过程中遇到的问题。

    今天通过 ant 执行 TestNG 测试用例时,执行报错,相应的错误信息如下所示:

    Buildfile: D:DevToolautoUI_64workspaceReportNGuild.xml
    init:
    compile:
    start_server_and_run_tests:
    init:
    compile:
    run_tests:
       [delete] Deleting directory D:DevToolautoUI_64workspaceReportNG	est-output
        [mkdir] Created dir: D:DevToolautoUI_64workspaceReportNG	est-output
       [testng] java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
       [testng]     at java.lang.Class.getDeclaredMethods0(Native Method)
       [testng]     at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
       [testng]     at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
       [testng]     at java.lang.Class.getMethod0(Class.java:3018)
       [testng]     at java.lang.Class.getMethod(Class.java:1784)
       [testng]     at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
       [testng]     at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
       [testng] Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException
       [testng]     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
       [testng]     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
       [testng]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
       [testng]     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
       [testng]     ... 7 more
       [testng] Error: A JNI error has occurred, please check your installation and try again
    
    BUILD FAILED
    D:DevToolautoUI_64workspaceReportNGuild.xml:24: The following error occurred while executing this line:
    D:DevToolautoUI_64workspaceReportNGuild.xml:31: The tests failed.
    
    Total time: 832 milliseconds

    究其原因是因为缺失了 jcommander.jar ,加入 jcommander.jar 引用后,问题圆满解决。

    jcommander.jar 可在 Maven Repository 下载

     

    至此, Ant学习-002-ant 执行 TestNG 测试用例时 [testng] java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException 解决方案 顺利完结,希望此文能够给初学 ant 的您一份参考。

    最后,非常感谢亲的驻足,希望此文能对亲有所帮助。热烈欢迎亲一起探讨,共同进步。非常感谢! ^_^

     

  • 相关阅读:
    innodb的innodb_buffer_pool_size和MyISAM的key_buffer_size(转自:http://www.java123.net/898181.html)
    mysql max_allowed_packet参数值改大后,莫名被还原
    windows MySQL5.7.9免安装版配置方法
    centos7.2启动级别
    saltstack
    Jmeter -- 参数化(函数助手和CSV数据文件配置)
    Jmeter -- 上下文关联(JSON提取器)
    LBS 基于位置的服务
    uiautomatorviewer报错 Error taking device screenshot: EOF
    python中加入中文注释报错处理
  • 原文地址:https://www.cnblogs.com/fengpingfan/p/4705556.html
Copyright © 2020-2023  润新知