运行带有已配置的ReportNG的TestNG xml文件时出现java.lang.NoClassDefFoundError

时间:2017-10-22 05:21:59

标签: reportng

我是Selenium的新手,使用已配置的ReportNG运行我的第一个TestNG。我已执行以下所有必需步骤。请帮助您输入。谢谢!

  1. 将以下JAR添加到项目中 guice 3.0 速度1.4 reportng 1.1.4
  2. 已禁用TestNG的默认侦听器
  3. 将ReportNG侦听器添加到xml

    XML文件:                                                                                      

  4. 将.xml作为TestNG套件运行后,出现以下错误。类定义看起来很好......下面的快照......

      package SeleniumProject;
    
      <<Import statements go here>>
    
         public class Test1DemoautBookTicket {
    
            --------
         }
    
    
    Error:
    

    java.lang.NoClassDefFoundError: org/apache/commons/collections/ExtendedProperties at org.apache.velocity.runtime.RuntimeInstance.<init> (RuntimeInstance.java:160) at org.apache.velocity.runtime.RuntimeSingleton.<clinit> (RuntimeSingleton.java:95) at org.apache.velocity.app.Velocity.setProperty(Velocity.java:117) at org.uncommons.reportng.AbstractReporter.<init>(AbstractReporter.java:62) at org.uncommons.reportng.HTMLReporter.<init>(HTMLReporter.java:83) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.testng.internal.ClassHelper.newInstance(ClassHelper.java:50) at org.testng.TestNG.initializeConfiguration(TestNG.java:914) at org.testng.TestNG.run(TestNG.java:1022) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.ExtendedProperties at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 16 more

    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
       <suite name="FirstSelenium">
       <listeners>
         <listener class-name="org.uncommons.reportng.HTMLReporter"/>
         <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
       </listeners>
          <test name="Test1"> 
                <classes>
                <class name="SeleniumProject.Test1DemoautBookTicket"></class>
                </classes>
         </test>
        </suite>
    

1 个答案:

答案 0 :(得分:0)

我从jar-download.com下载了ReportNG广告罐。 这些文件中还有一个名为 velocity-dep-1.4.jar 的文件。在我将它添加到项目之前,我得到了与你相同的错误。

(禁用默认侦听器似乎没有必要。)