簡體   English   中英

神秘的螞蟻劇本

[英]Mysterious Ant script

我的Ant腳本有問題。 我必須在ant run上運行junit測試。

我當前的腳本如下:

<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="doc" location="doc"/>
<property name="dist" location="dest"/>
<property name="lib" location="lib"/>
<property name="app" value="${ant.project.name}.jar"/>

<presetdef name="javac">
    <javac includeantruntime="false"/>
</presetdef>

<target name="clean">
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
</target>

<target name="compile" depends="clean" description="Compile">
    <mkdir dir="${build}"/>
    <javac srcdir="${src}"
           destdir="${build}" 
           classpath="${lib}/junit-4.10.jar:${lib}/swing-layout-1.0.4.jar:${src}">
    </javac>
    <copy todir="${build}/checkers">
        <fileset dir="${lib}">
            <include name="resources/**" />
        </fileset>
    </copy>
</target>
<target name="run" depends="compile">
    <echo>Running the junit tests...</echo>
    <junit showoutput="no" fork="no">
        <classpath>
            <pathelement location="${build}"/>   
            <pathelement path="${build}:${lib}/junit-4.10.jar"/>
        </classpath>
        <formatter type="plain" usefile="false" />
        <test name="checkers.CheckersTest"/>
    </junit>
</target>

在我的Linux機箱測試運行正常,一切看起來不錯。 但在我的Windows上,Ant給了我很好的:

java.lang.NoClassDefFoundError: junit/framework/TestListener

但調試模式下的Ant告訴我他從上面的junit-4.10.jar文件中加載了TestListener.class。

試試這個答案http://youtrack.jetbrains.com/issue/TW-4882

To fix the problem you should either use fork="true" attribute for 
junit task (in this case classpath will be created correctly), or 
to copy junit.jar to ANT_HOME/lib (to ensure correct class loading). 

這也是這個https://bugs.eclipse.org/bugs/show_bug.cgi?id=36198的錯誤。 最后評論說JUnit is available in Ant via the org.eclipse.ant.optional.junit fragment

暫無
暫無

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

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