2013-12-09 27 views
0
<target name="run-junit-test" depends="javac"> 
    <mkdir dir="testReports"/> 
    <junit printsummary="yes" haltonfailure="yes"> 
     <classpath refid="project.class.path"/> 
     <formatter type="plain"/> 
     <formatter type="xml" /> 
     <batchtest todir="testReports" fork="yes"> 
      <fileset dir="src"> 
       <include name="**/*Test*.java" /> 
      </fileset> 
     </batchtest> 
    </junit> 
</target> 

这是我的build.xml文件当我运行测试,并报告文件具有所有日志中像在ant build.xml中的Junit测试打印完整的堆栈跟踪,如何只打印结果?


INFO - Refreshing org.[email protected]7632efa7: display name [org.[email protected]7632efa7]; startup date [Mon Dec 09 18:05:51 IST 2013]; root of context hierarchy 
INFO - Loading XML bean definitions from file [/home/user/Desktop/RangdeDev/src/applicationContext.xml] 
INFO - Loading XML bean definitions from file [/home/user/Desktop/RangdeDev/src/applicationContext-hibernate.xml] 
INFO - Loading XML bean definitions from file [/home/user/Desktop/RangdeDev/src/applicationContext-quartz.xml] 
INFO - Overriding bean definition for bean 'GMAIT_T': replacing [Root bean: class [org.springframework.beans.factory.config.FieldRetrievingFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [org.springframework.beans.factory.config.FieldRetrievingFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] 
INFO - Overriding bean definition for bean 'ALDEN_1': replacing [Root bean: class [org.springframework.beans.factory.config.FieldRetrievingFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [org.springframework.beans.factory.config.FieldRetrievingFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] 
INFO - Overriding bean definition for bean 'mailHelper': replacing [Root bean: class [org.rangde.service.MailHelper]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/home/user/Desktop/RangdeDev/src/applicationContext.xml]] with [Root bean: class [org.rangde.service.MailHelper]; scope=singleton; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/home/user/Desktop/RangdeDev/src/applicationContext-quartz.xml]] 
INFO - Bean factory for application context [org.[email protected]7632efa7]: org.s[email protected]7cbe41ec 
INFO - Loading properties file from file [/home/user/Desktop/RangdeDev/WebContent/WEB-INF/jdbc.properties] 
INFO - Loading properties file from file [/home/user/Desktop/RangdeDev/WebContent/WEB-INF/jdbc.properties] 
INFO - Loading properties file from file [/home/user/Desktop/RangdeDev/WebContent/WEB-INF/jdbc.properties] 
INFO - Pre-instantiating singletons in org.s[email protected]7cbe41ec: defining ---- 

如何打印测试的唯一输出像

Testcase: testPrintMessage took 0.004 sec 
    FAILED 
expected:<[11]> but was:<[97]> 
junit.framework.AssertionFailedError: expected:<[11]> but was:<[97]> 
    at tests.TestJunit.testPrintMessage(TestJunit.java:13) 

回答

1

我认为你必须改变日志级别警告/错误(我不知道你使用的是什么日志记录器)。

正如你可以看到它打印了很多INFO行,你不需要在这一刻。