testing - JUnit - Access failure messages in tearDown() -
i did search already, found 1 topic on nunit. guess junit still bit different nunit going foreward ask question ;-)
i have 1 test case setup(), test() , teardown(). instead of throwing exeptions in setup() , test() use function fail("some text here..."); there asserts because of test might teminate. want reason failure of test case in teardown() function (which prolbem) , write string file (which no problem if failure reason). question is, how can access information failure of test case? how can check if test failed @ in teardown() function?
regards, sh
here programmatic way this.
throwable thrownexception = null; @before public void setup{ thrownexception = null; } @test public void test(){ try{ // test here } catch (throwable t){ thrownexception = t; throw t; } } @after public void cleanup(){ if (thrownexception != null) .... } another option create custom rule need in case of failure.
Comments
Post a Comment