unit testing - How to make jmunit run all tests and still fail at the end if any tests failed -


when switch off haltonfailure or haltonerror in jmunit tests this:

<jmunit haltonerror="false" haltonfailure="false" failureproperty="testfailure">     <formatter type="xml" />     <classpath>         <path path="${jar_location}" />         <path path="${build}" />     </classpath>     <!-- add  -->     <test name="com.example.tests.test1" todir="${reports}" />     <test name="com.example.tests.test2" todir="${reports}" />     <test name="com.example.tests.etc" todir="${reports}" /> </jmunit > 

the build succeeds when tests failed. if turn halts on, of course halts upon first failure. behaviour want tests executed regardless of how many of them fail, if of them failed build won't successful. reason want reports can correctly show how many passes , failures, , tests failing.

how achieve this? and/or thinking want of tests run flawed?

easy peasy:

you need add command

<fail message="something went wrong. please check test results." if="testfailure" /> 

to target contains jmunit command after jmunit command itself.

this way, jmunit task set variable testfailure when 1 of tests fails , command fail make build unsuccessful if property set.

hope helps.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -