ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: junit can't find test classes
Date Fri, 23 May 2003 02:38:31 GMT

Here's the relevant info from the following build file for running JUnit 
tests and it works just fine....
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/prevayler/prevayler/build.xml


build.properties...

# ----- unit test setup ------
unit.test.includes=**/CheckpointPrevaylerTest.java \
                    ,**/SnapShotPrevaylerTest.java \
                    ,**/util/clock/ClockedTransactionTest.java \
                    ,**/test/*Test*.java
unit.test.excludes=


build.xml...

<property name="unit.test.home"         location="${basedir}/unit_tests" />
<property name="unit.test.report.home"  location="${unit.test.home}/reports" />
<property name="src.test.home"          location="${src.home}/test" />
<property name="log4j.system.variable.name" value="${app.name}.log.home" />
<property name="log4j.log.path" location="${basedir}/logs" />

<fileset dir="${src.test.home}" id="unit.test.files"
          includes="${unit.test.includes}"
          excludes="${unit.test.excludes}" />

<path id="build.test.classpath" >
     <pathelement location="${build.home}" />
     <path refid="build.classpath" />
</path>

<target name="test" depends="compile.test"
         description="Runs JUnit tests" >

     <mkdir dir="${unit.test.home}" />
     <mkdir dir="${unit.test.report.home}" />
     <junit dir="${unit.test.home}" printsummary="yes" haltonfailure="no" 
fork="yes" >
         <classpath refid="build.test.classpath" />
         <sysproperty
             key="${log4j.system.variable.name}"
             value="${log4j.log.path}" />
         <!--<sysproperty
             key="log4j.configuration"
             value="file:./log4j.xml" />-->
         <formatter
             type="xml"
             usefile="yes" />
         <batchtest todir="${unit.test.report.home}" >
             <fileset refid="unit.test.files" />
         </batchtest>
     </junit>
     <antcall target="-test.report.html" />

</target>

<target name="-test.report.html" >
         <!--description="Convert the junit xml files to html" -->

     <junitreport todir="${unit.test.report.home}" >
         <fileset dir="${unit.test.report.home}" >
             <include name="TEST-*.xml" />
         </fileset>
         <report
             format="frames"
             todir="${unit.test.report.home}/html" />
     </junitreport>

</target>

Hope that helps.

Jake

At 07:49 PM 5/22/2003 -0400, you wrote:
>This has been driving me nuts all day!
>
>I've got some junit test classes that I know work, but I can't get a build
>script to find them, although it seems like it does. Here's the target:
>
><target name="test" depends="compile" description="Execute unit tests">
>   <junit printsummary="yes" >
>     <formatter type="plain" />
>     <batchtest>
>       <fileset dir = "${build.dir}">
>          <include name="**/*Test.class"/>
>       </fileset>
>    </batchtest>
>   </junit>
>  </target>
>
>Here's what it says when it runs:
>
>test:
>     [junit] Running classes.AccountTest
>     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>     [junit] TEST classes.AccountTest FAILED
>     [junit] Running classes.AcctInTest
>     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>     [junit] TEST classes.AcctInTest FAILED
>     [junit] Running classes.AcctOutTest
>     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>     [junit] TEST classes.AcctOutTest FAILED
>
>So this seems to indicate that it did in fact find the test classes, but
>here's what the reports say about each test class:
>
>Testsuite: classes.AccountTest
>Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>
>         Caused an ERROR
>classes.AccountTest
>java.lang.ClassNotFoundException: classes.AccountTest
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:140)
>
>It must be something dumb I'm doing, but I sure can't see it.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message