Dilip Joshi
Dilip Joshi

Reputation: 13

Ant build Error: when I try to run This error will generate

root@ubuntu:/home/dj/workspace/TestProject# ant test
Buildfile: /home/dj/workspace/TestProject/build.xml

test:
    [junit] Testsuite: TestProject
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
    [junit] 
    [junit]     Caused an ERROR
    [junit] TestProject
    [junit] java.lang.ClassNotFoundException: TestProject
    [junit]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    [junit]     at java.security.AccessController.doPrivileged(Native Method)
    [junit]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    [junit]     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    [junit]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    [junit]     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    [junit]     at java.lang.Class.forName0(Native Method)
    [junit]     at java.lang.Class.forName(Class.java:169)
    [junit] 

BUILD FAILED
/home/dj/workspace/TestProject/build.xml:17: Test TestProject failed

Total time: 0 seconds
<project name="TestProject" basedir="." default="" >
<property name="src" value="./src" />
<property name="lib" value="./lib" />
<property name="classes" value="./classes" />
<property name="ant.project.name" value="com.megacorp.projx.util" />

    <path id="test.classpath">
      <pathelement location="${classes}" />
      <pathelement location="usr/junit.jar" />
      <fileset dir="${lib}">
        <include name="**/*.jar"/>
      </fileset>
    </path>

    <target name="test">
      <junit fork="yes" haltonfailure="yes">
        <test name="${ant.project.name}" />
        <formatter type="plain" usefile="false" />
        <classpath refid="test.classpath" />
      </junit>
    </target>

Upvotes: 0

Views: 347

Answers (1)

oers
oers

Reputation: 18704

This is wrong:

<test name="${ant.project.name}" />

Here you should set the name of the junit-class you want to test, and not the name of the ant project.

E.g.:

<test name="myorg.MyTest" />

Links:
Documentation for junit task: have a look at the examples at the Bottom

Upvotes: 0

Related Questions