Failing a build if a junit test fails in an intelligent way
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Hayden_Marchant
Posted On:   Thursday, October 17, 2002 01:08 AM

I am running a whole load of junit tasks in our build by doing antcall lots of time - there is a target for each junit test. I need to run all the tests, then run a junitreport, and after that fail the build if one of the tests have failed. My junit task is like this: ...... and I'm calling all the tests from a master target like this: .............................. .............................. I am setting a ${test.failed} property on error/failure in each target, but I can't seem to access this property outside of the scope of each target - i.e. from m   More>>

I am running a whole load of junit tasks in our build by doing antcall lots of time - there is a target for each junit test. I need to run all the tests, then run a junitreport, and after that fail the build if one of the tests have failed.


My junit task is like this:







......


and I'm calling all the tests from a master target like this:







..............................

..............................


I am setting a ${test.failed} property on error/failure in each target, but I can't seem to access this property outside of the scope of each target - i.e. from my calling target. I think that this is because the scope of the property is local. However, if I have a globally defined property, it's immutable.


What I need is a variable - something that I can set within 1 target, and read within another target. Is there any way I can do this, apart from making a file as a marker, etc...

   <<Less

Re: Failing a build if a junit test fails in an intelligent way

Posted By:   Erik_Hatcher  
Posted On:   Thursday, October 17, 2002 06:23 PM

No, besides making a property file (perhaps with or ) you cannot really pass variables back "up" the call stack. Properties are immutable as you said, and properties set in an do not propogate.

Re: Failing a build if a junit test fails in an intelligent way

Posted By:   Joshua_Tharp  
Posted On:   Thursday, October 17, 2002 10:07 AM

I've addressed a similar issue with a pair of tasks... A little background first: all of my tests are in a single source tree, but that shouldn't be an issue if you use filesets. You could easily add the failureProperty to the junit task I have listed below.





















About | Sitemap | Contact