Hi all,
We are working on a WPF desktop automation project. We have created a framework consisting of 60 heavy cases. The application itself has some performance issues, so due to waits or some unavailable services, tests may fail at any steps, which are really hard to guess. Ideally, we should open and close the app for each test, but it almost doubles the execution time since it takes almost one minute for the app to load. In short, I am looking for some method which will do the following:
If the test case fails, then close the app and open it again, else continue with the next case.
I found this method from the forum but it was written in 2012 and is now obsolete (https://www.ranorex.info/conditional-if ... t3791.html)
ITestCase iCase = TestSuite.Current.GetTestCase("TestCase1"); // The name of your Test Case
if(iCase.Status == Ranorex.Core.Reporting.ActivityStatus.Failed){
Report.Info("TestCase1 Failed!");
}
Alternatively,
if (Ranorex.Core.Testing.TestCase.Current.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Failed))
//...
else
//..
Does anyone know a current method for this?
Thanks in advance.
Conditional If testcase fails then else
Re: Conditional If testcase fails then else
Hi,
I think this code should do the trick...
I think this code should do the trick...
Code: Select all
var iCase = TestSuite.Current.GetTestContainer("TestCase1"); // The name of your Test Case
if (iCase.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Failed))
{
Report.Info("TestCase1 Failed!");
}
else
{
...
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Conditional If testcase fails then else
Thanks for the response. But in this code, I will need to write always the previous test case name by hardcoding. The order of the cases may change in time and it will cause my code not to run. Like in the code below, it should take the current test case dynamically. Is that possible?
if (Ranorex.Core.Testing.TestCase.Current.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Failed))
//...
else
//..
if (Ranorex.Core.Testing.TestCase.Current.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Failed))
//...
else
//..