`
zzkathy
  • 浏览: 42428 次
  • 性别: Icon_minigender_2
  • 来自: 上海
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

ant学习笔记(四)

阅读更多

昨天在运行ant进行junit测试的时候不停的报错:    [junit] java.io.FileNotFoundException: junitvmwatcher***.properties (系统找不到指定的文件)然后怎么都查不出错误,今天早上也同样没有解决。而且只有<batchtest>才会出问题,<test>是OK的。

下面的是我的ant脚本,原来没有红色的一行。

<!-- run junit -->
<target name="junit" depends="compilejunit">
    <junit printsummary="yes" haltonfailure="yes" >
        <classpath>
            <fileset dir="${plugin.depend}">
                <include name="**/*.jar"/>
                <exclude name="**/ant*.jar"/>
            </fileset>
            <pathelement location="${junit.bin}"/>
        </classpath>

        <test name="${release.checher}"
                  haltonfailure="yes"
                  todir="${junit.report.dir}"
                  >
            <formatter type="xml"/>
        </test>

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

直到后来google,终于发现了问题所在:虽然系统环境变量中设置的是1.7.0的ant,但是在load需要的jar的时候load了eclipse自带的1.6.2的ant,而1.7.0是不会有这种问题的。<test>用的是现有的环境变量设置,所以不会有问题,而<batchtest>是fork出来,使用了<classpath>中的设置的。

发现了问题,解决起来自然很快,exclude旧版本的ant就行了~~如上红色:)

分享到:
评论
2 楼 joeytang 2009-07-29  
非常期待能给与帮助,谢谢。
1 楼 joeytang 2009-07-29  
你好我按照你说的方法改了以后还是提示同样的错误。我把 我的build.xml贴出来,麻烦帮忙看一下好吗。万分感激。

<target name="mytest-junit" depends="mybuild-test">
<delete dir="${build.dir}/junit/reports"></delete>
<mkdir dir="${build.dir}/junit/reports"/>
<!-- on:在独立虚拟机中进行运行测试 -->
<junit fork="yes" printsummary="yes" haltonfailure="yes" showoutput="true">
<classpath>
<fileset dir="${lib.dir}/release">
<include name="*.jar"/>
<exclude name="**/ant*.jar"/>
</fileset>
<fileset dir="${deploy.dir}/WEB-INF/classes">
<include name="**/*.*"/>
<exclude name="**/ant*.jar"/>
</fileset>
</classpath>
<formatter type="xml"/>
<batchtest fork="yes" haltonfailure="yes" todir="${build.dir}/junit/reports">
<fileset dir="${src.dir}/test/java">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${build.dir}/junit/reports">
<fileset dir="${build.dir}/junit/reports">
<include name="*.xml" />
</fileset>
<report format="frames" todir="${build.dir}/junit/reports" />
</junitreport>
</target>

相关推荐

Global site tag (gtag.js) - Google Analytics