problem mit JUnit tests mit Ant in Eclipse. Anfänger-Frage

Ich Lerne in diesen Tagen, wie die Verwendung von ant ausführen automatisierter Tests dazu diese tutorial.

Habe ich JUnit in den classpath meines Projekts. Alle scheinen gut zu funktionieren und ich kann es in meinem Unterricht:

import junit.framework.TestCase; //line20

public class SimpleLattice1DTest extends TestCase{
 ...
}

Meine build.xml ist:

<?xml version="1.0"?>
<project name="Ant-Test" default="compile" basedir=".">
    <!-- Sets variables which can later be used. -->
    <!-- The value of a property is accessed via ${} -->
    <property name="src.dir" location="." />
    <property name="build.dir" location="build" />
    <property name="dist.dir" location="dist" />
    <property name="docs.dir" location="docs" />
    <property name="test.dir" location="jlife/tests" />
    <property name="test.report.dir" location="test/report" />  

    <!-- Deletes the existing build, docs and dist directory-->
    <target name="clean">
        <delete dir="${build.dir}" />
        <delete dir="${docs.dir}" />
        <delete dir="${dist.dir}" />
    </target>

    <!-- Creates the  build, docs and dist directory-->
    <target name="makedir">
        <mkdir dir="${build.dir}" />
        <mkdir dir="${docs.dir}" />
        <mkdir dir="${dist.dir}" />

        <mkdir dir="${test.report.dir}" />


    </target>

    <!-- Compiles the java code (including the usage of library for JUnit -->
    <target name="compile" depends="clean, makedir">
        <javac srcdir="${src.dir}" destdir="${build.dir}">
        </javac>

    </target>

    <!-- Creates Javadoc -->
    <target name="docs" depends="compile">
        <javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
            <!-- Define which files /directory should get included, we include all -->
            <fileset dir="${src.dir}">
                <include name="**" />
            </fileset>
        </javadoc>
    </target>

    <!--Creates the deployable jar file  -->
    <target name="jar" depends="compile">
        <jar destfile="${dist.dir}\CoreTest.jar" basedir="${build.dir}">
            <manifest>
                <attribute name="Main-Test" value="test.CoreTest" />
            </manifest>
        </jar>
    </target>


    <!-- Run the JUnit Tests -->
        <!-- Output is XML, could also be plain-->
        <target name="junit" depends="compile">
            <junit printsummary="on" fork="true" haltonfailure="yes">

                <formatter type="xml" />
                <batchtest todir="${test.report.dir}">
                    <fileset dir="${src.dir}">
                        <include name="**/*Test*.java" />
                    </fileset>
                </batchtest>
            </junit>
        </target>

</project>

Wenn ich es in eclipse bekomme ich die folgende Fehlermeldung:

[javac] C:\Documents und
Einstellungen\noname\Documenti\JLife_git\JLife_git\JLife\src\jlife\tests\SimpleLattice1DTest.java:20:
Paket junit.Rahmen nicht existiert
[javac] import junit.Rahmen.TestCase;

Ich nehme an, es ist etwas falsch mit ihm, aber ich habe keine Ahnung. Könnte jemand mich in die richtige Richtung?

Übrigens, die 'junit.Rahmen.TestCase' - Klasse ist Teil des JUnit-3. JUnit-4 hat eine Reihe von Verbesserungen, so würde ich empfehlen, dass, wenn Sie können.

InformationsquelleAutor Heisenbug | 2011-09-25

Schreibe einen Kommentar