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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -