簡體   English   中英

使用配置的ReportNG運行TestNG xml文件時出現java.lang.NoClassDefFoundError

[英]java.lang.NoClassDefFoundError while running TestNG xml file with configured ReportNG

我是Selenium的新手,使用配置的ReportNG運行我的第一個TestNG。 我已經執行了以下所有必需步驟。 請幫助您的輸入。 謝謝!

  1. 在項目向導3.0 Velocity 1.4 reportng 1.1.4中添加了以下JAR
  2. 禁用TestNG的默認偵聽器
  3. 在XML中添加了ReportNG偵聽器

    XML檔案:

將.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>

我從jar-download.com下載了ReportNG jar。 這些文件中還有一個名為Velocity-dep-1.4.jar的文件。 在將其添加到項目中之前,我遇到了與您相同的錯誤。

(似乎沒有必要禁用默認偵聽器。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM