単純なjunitテストクラスを実行すると、java.lang.ClassNotFoundExceptionが発生し続けます。何が悪いのかわかりません..これが私のファイルシステムです。メインアプリは正常にコンパイルされています。これは私のantファイルです:
<project name="MyProject" default="dist" basedir=".">
<description>
controller build
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="TALK" value="true" />
<path id="class.path">
<fileset dir="..\lib">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.classpath">
<pathelement location="${build}" />
<pathelement location="..\lib\junit\junit.jar" />
<fileset dir="..\lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" verbose="${TALK}">
<classpath refid="class.path" />
</javac>
</target>
<target name="dist" depends="compile,test"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/controller.jar" basedir="${build}"/>
</target>
<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
<target name="test" depends="compile">
<junit printsummary="yes" showoutput="true">
<classpath refid="test.classpath"/>
<formatter type="brief" usefile="false" />
<test name="workflowShouldHaveValidXML" />
<!--test name="environmentHasValidXml" /-->
<!--test name="workflowHasValidXml" /-->
</junit>
</target>
</project>
これは私が得ているエラーです:
D:\svn\trunk\controller>ant -f build_controller.xml
Buildfile: D:\svn\trunk\controller\build_controller.xml
init:
compile:
[javac] D:\svn\trunk\controller\build_controller.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false
for repeatable builds
test:
[junit] Running workflowShouldHaveValidXML
[junit] Testsuite: workflowShouldHaveValidXML
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit]
[junit] Null Test: Caused an ERROR
[junit] workflowShouldHaveValidXML
[junit] java.lang.ClassNotFoundException: workflowShouldHaveValidXML
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:264)
[junit]
[junit]
[junit] Test workflowShouldHaveValidXML FAILED
dist:
BUILD SUCCESSFUL
Total time: 0 seconds
これは私のディレクトリ構造です:
svn\trunk\controller\build_controller.xml \\ Ant file
svn\trunk\controller\src\com\controller\core\*.java \\ main app sources
svn\trunk\controller\dist\lib\controller.jar \\ the main product
svn\trunk\controller\build\com\controller\core\*.class \\the main product *.class
svn\trunk\controller\test\com\controller\core\workflowShouldHaveValidXML.java \\ the test case class
svn\trunk\lib\junit\junit.jar
svn\trunk\lib\java\*.jar \\ third party jars