User code help

Ask general questions here.
peterbonney
Posts: 10
Joined: Tue Jun 25, 2013 2:13 pm

User code help

Post by peterbonney » Thu Sep 04, 2014 4:46 pm

Hi,

I have a recording module that i am using for teardown, however, I want to use it as a "Panic" tear down script for use when my proper tests haven't worked.

My panic teardown i'm using as the teardown for the test suite, each of my test cases has its own teardown that uses the UI to correctly select the logout option from within the web site and close the browser, whereas my panic teardown uses the websites URL with /logout at the end to force the app in to a logged out state. when i run my tests and everything is hunky dory as i'd expect the panic logout fails, which is going to screw my results.

So what i want is a bit of user code that says if a teardown fail, it runs my panic teardown and continues on with the next test case, or, if everything is good, just ignore my panic teardown. If this is not possible, i'd be happy with it just seeing that the browser is open and that triggering ranorex to run my panic teardown.

Any help on this would be fab, my solution is in C#

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: User code help

Post by krstcs » Thu Sep 04, 2014 6:10 pm

Since the teardown is still inside the "current" test case iteration, you should be able to get the current test case's status like this:

Code: Select all

if(TestCase.Current.Status == Ranorex.Core.Reporting.ActivityStatus.Failed) { 
  //do your teardown stuff here... 
}
Shortcuts usually aren't...