user2783484
user2783484

Reputation: 949

Junit Test in ant build.xml prints full stack trace, how to print only result?

<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>

This is my build.xml file when i run the test and report file has all logs in it like


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 ----

How can i print only output of the test like

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)

Upvotes: 0

Views: 369

Answers (1)

Adam Arold
Adam Arold

Reputation: 30538

I think you have to change the logging level to warn/error (I don't know what logger are you using).

As you can see it prints a lot of INFO lines which you don't need at the moment.

Upvotes: 1

Related Questions