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

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -