|
用ant+junit建立自动化单元测试,总是提示找不到对应的类文件,编译已经成功了的。用debug信息也看到加载了对应的类文件(AllTestSuite.class)。但就是一直提示错误,大家帮我看看,或者有什么好的方法可以定位呢?
省略号加载表示加载的东西太多,把不必要的就省掉了.
daily_build.xml:
........
<target name="compile" depends="update">
<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir.app}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="build" depends="compile">
<jar destfile="${build.dir}/${build.name.jar}" basedir="${classes.dir}"/>
</target>
<!--For Unit testing Compile-->
<target name="UnitCompile" depends="build">
<javac srcdir="${test.dir}" destdir="${testClasses.dir}" debug="true">
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir.app}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="/home/nexus/SVN/dailyBuilding/sourceCode/Library/test">
<include name="**/*.jar"/>
</fileset>
<fileset dir="/home/nexus/SVN/dailyBuilding/lib/org.junit4_4.1.0.1">
<include name="junit-4.1.jar"/>
</fileset>
</classpath>
</javac>
<copy todir="${testClasses.dir}">
<fileset dir="${test.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!--End For Unit testing Compile-->
<!--Run Unit Testing-->
<target name="test" depends="UnitCompile">
<mkdir dir="${report.xml}"/>
<mkdir dir="${report.html}"/>
<junit printsummary="yes" haltonfailure="no">
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir.app}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="/home/nexus/SVN/dailyBuilding/sourceCode/Library/test">
<include name="**/*.jar"/>
</fileset>
<fileset dir="/home/nexus/SVN/dailyBuilding/lib/org.junit4_4.1.0.1">
<include name="junit-4.1.jar"/>
</fileset>
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
</classpath>
<formatter type="xml"/>
<batchtest fork="yes" todir="${report.xml}">
<fileset dir="${testClasses.dir}" includes="**/*AllTest*.class"/>
</batchtest>
</junit>
<junitreport todir="${report.html}">
<fileset dir="${report.xml}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${report.html}"/>
</junitreport>
</target>
<!--End For Run Unit Testing-->
.........
错误:
<error message="com.nexus.nexusscene.AllTestSuite" type="java.lang.ClassNotFoundException">java.lang.ClassNotFoundException: com.nexus.nexusscene.AllTestSuite
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
</error>
对应的debug信息:
。。。。。。。。。。。。。
'-classpath'
......
:/home/nexus/SVN/dailyBuilding/sourceCode/MSCR/MSCR_Business/build/testClasses/com/nexus/nexusscene/AllTestSuite.class
......
。。。。。。。。。。
:/usr/apache-ant-1.7.0/lib/ant-launcher.jar:/usr/apache-ant-1.7.0/lib/ant.jar:/usr/apache-ant-1.7.0/lib/ant-junit.jar'
'org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner'
'com.nexus.nexusscene.AllTestSuite'
'filtertrace=true'
'haltOnError=false'
'haltOnFailure=false'
'formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter'
'showoutput=false'
'outputtoformatters=true'
'logtestlistenerevents=true'
'formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,/home/nexus/SVN/dailyBuilding/sourceCode/MSCR/MSCR_Business/report/junit/xml/TEST-com.nexus.nexusscene.AllTestSuite.xml'
'crashfile=/home/nexus/SVN/dailyBuilding/sourceCode/MSCR/MSCR_Business/junitvmwatcher1579461855.properties'
'propsfile=/home/nexus/SVN/dailyBuilding/sourceCode/MSCR/MSCR_Business/junit73032522.properties'
The ' characters around the executable and arguments are
not part of the command.
[junit] Running com.nexus.nexusscene.AllTestSuite
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
fileset: Setup scanner in dir /home/nexus/SVN/dailyBuilding/sourceCode/MSCR/MSCR_Business/report/junit/xml with patternSet{ includes: [*.xml] excludes: [] } |
|