<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文件,并且报告文件中包含所有日志,如
INFO - Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@7632efa7: display name [org.springframework.context.support.FileSystemXmlApplicationContext@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.springframework.context.support.FileSystemXmlApplicationContext@7632efa7]: org.springframework.beans.factory.support.DefaultListableBeanFactory@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.springframework.beans.factory.support.DefaultListableBeanFactory@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)
答案 0 :(得分:1)
我认为您必须将日志记录级别更改为警告/错误(我不知道您使用的是哪种记录器)。
正如您所看到的那样,它会打印出许多您当前不需要的INFO
行。