Gradle test: how to do something even if the tests fail -


my current test task looks this:

test {     dofirst {         println 'starting application...'         thread.startdaemon {             appprocess = testserverexec.execute()         }         sleep 20000 // wait thread start     }      dolast {         appprocess.destroy()     } } 

i've noticed if tests pass, appprocess.destroy() called , everyone's happy. however, if tests fail, thread lingers , have kill process myself. know gradle has try/finally, i'm not sure how use correctly in case. basically, want appprocess.destroy() run, if tests fail.

how might go it?

edit: discovered beforesuite , aftersuite, run multiple suites of tests , want thread started before suites, , killed after suites.

you can use aftersuite , check suite null parent. root suite:

test{     aftersuite{descr, result ->         if(desc.parent == null){             //put logic here         }     } } 

hope helps,

cheers, rené


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -