2013-07-23 160 views
1

我有一个单独的junit测试用例,它与ant脚本集成在一起。独立的junit工作正常,测试用例通过。当它与ant集成执行时​​,它会失败。Junit Ant集成问题

测试用例和蚂蚁脚本是如下,

import org.junit.Test; 

public class SimpleTest 
{ 

    @Test 
    public void testHello() 
    { 
     System.out.println("Hello"); 
    } 


} 

ant脚本是,

<property file="build.properties" /> 

<path id="libirary"> 

    <fileset dir="${lib}"> 
     <include name="**.*jar" /> 
    </fileset> 

</path> 




<target name="clean"> 
    <delete dir="${build.classes.dir}" /> 
    <delete dir="${build.dir}" /> 
    <delete dir="${dist.dir}" /> 
</target> 

<target name="init" depends="clean"> 
    <mkdir dir="${build.classes.dir}" /> 
    <mkdir dir="${dist.dir}" /> 
</target> 


<target name="compile" depends="init"> 
    <javac encoding="ISO-8859-1" destdir="${build.classes.dir}" srcdir="${src.dir}"> 
     <classpath> 
      <path refid="libirary" /> 
     </classpath> 
    </javac> 
</target> 

<target name="jar" depends="compile"> 

    <jar destfile="${dist.dir}/${jar.filename}.jar"> 

     <fileset dir="${build.classes.dir}" /> 
     <zipfileset dir="${lib}" includes="**/*.jar" /> 

     <manifest> 
      <attribute name="Main-Class" value="${main.file.name}" /> 
     </manifest> 

    </jar> 
</target> 


<target name="junit" depends="compile"> 
    <junit printsummary="yes" description="true" filtertrace="yes" > 

     <classpath path="${lib}"> 
      <path refid="libirary" /> 
     </classpath> 
     <test name="SimpleTest"> 
     </test> 
    </junit> 
</target> 

输出是,

Buildfile: D:\Workspaces\TrunkForCheckIn-31-05-2013\PG\build.xml 
clean: 
    [delete] Deleting directory 
    [delete] Deleting directory 
    [delete] Deleting directory 
init: 
    [mkdir] Created dir: 
    [mkdir] Created dir: 
compile: 
    [javac] warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds 
    [javac] Compiling 57 source files to 
    [javac] Note: Some input files use unchecked or unsafe operations. 
    [javac] Note: Recompile with -Xlint:unchecked for details. 
junit: 
    [junit] Running SimpleTest 
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec 
    [junit] Test com.bosch.in.stepage.pg.SimpleTest FAILED 
BUILD SUCCESSFUL 
Total time: 1 second 

回答

2

尝试添加一个普通的格式化:

<target name="junit" depends="compile"> 
    <junit printsummary="yes" description="true" filtertrace="yes" > 
    <formatter type="plain" usefile="false" /> 
     <classpath path="${lib}"> 
      <path refid="libirary" /> 
     </classpath> 
     <test name="SimpleTest"> 
     </test> 
    </junit> 
</target> 
+0

感谢您的答复 喜从冗长我能发现找不到类的例外是事业,甚至给下面的代码之后,是不拾取类, \t \t \t \t \t \t \t vvekselva