0
我正在通過螞蟻對Jenkins運行Junit測試,並且我真的被這個錯誤困住了。Junit螞蟻詹金斯ClassNotFoundException
我的Ant文件的相關部分:
<!-- Get the Junit test files -->
<target name="getTest">
<svn svnkit="false" javahl="false">
<export srcUrl="${svn.junit}" destPath="${junit.dir}" />
</svn>
</target>
<!-- Compile Junit Test Files -->
<target name="test-compile" depends="compileJava">
<javac srcdir="${junit.dir}" target="1.6" source="1.6" destdir="${test.classes}">
<classpath>
<path refid="test.classpath" />
<pathelement location="${test.classes}" />
</classpath>
</javac>
</target>
<!-- Run JUnit Tests -->
<target name="test" depends="test-compile">
<junit haltonfailure="no" failureproperty="failed">
<classpath>
<path refid="test.classpath" />
<pathelement location="${test.classes}" />
</classpath>
<formatter type="xml" />
<batchtest fork="yes" todir="${test.reports}">
<fileset dir="${junit.dir}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
<fail message="TEST FAILER" if="failed" />
</target>
<path id="test.classpath">
<pathelement location="${basedir}/junit-4.11.jar" />
<pathelement location="${basedir}/ant-junit-1.8.4.jar" />
<pathelement location="${build.classes.dir}" />
<pathelement location="${build.lib.dir}" />
<pathelement location="${source.dir}" />
</path>
測試編譯成測試類文件夾,並在測試與控制檯輸出運行: [junit] Test com.some.app.ProjectName.MyTestClass FAILED
當你去查看測試結果測試它顯示堆棧跟蹤
java.lang.ClassNotFoundException: com.some.app.ProjectName.MyTestClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
是的,它是包聲明。謝謝。 – Cole9350