Page 1 of 1

Question on latest release notes

Posted: Tue Jul 17, 2012 5:37 pm
by carsonw
Hi there - just wondering if you could give a little more information on this note:
  • The result of a test case iteration can now be evaluated within teardown modules
I posted before about running subsets of larger tests, and wanting to be able to mark a test iteration as "skipped" (which is not currently possible) and I'm wondering if the above is a step in that direction. Thanks :)

Re: Question on latest release notes

Posted: Wed Jul 18, 2012 2:37 pm
by Support Team
Hi,

It means that you now can get the activity status of the current test case in the "teardown" of the test case.
As far as I know we posted a code snippet which achieved the explained functionality?

Regards,
Markus
Ranorex Support Team

Re: Question on latest release notes

Posted: Wed Jul 18, 2012 4:23 pm
by GeosoftRep
Support Team wrote: As far as I know we posted a code snippet which achieved the explained functionality?
Hello,

After looking through the release notes on the forum and website I do not see any code snippet explaining how this functionality works. Could you please provide it?

Thanks

Re: Question on latest release notes

Posted: Wed Jul 18, 2012 11:07 pm
by carsonw
Support Team wrote: As far as I know we posted a code snippet which achieved the explained functionality?
A code snippet when the request was originally made - or using the new functionality? We don't actually use "teardown" type tests, this would be skipping an iteration inside the current test case.

Re: Question on latest release notes

Posted: Thu Jul 19, 2012 8:32 pm
by GeosoftRep
  • The result of a test case iteration can now be evaluated within teardown modules
Pretty sure what this means is that, inside a teardown module you can do this:

if (Ranorex.Core.Testing.TestCase.Current.Status.Equals(Ranorex.Core.Reporting.ActivityStatus.Failed))
{
// Whatever code you place here will run if the TestCase this Teardown step belongs to has failed.
}

You could probably use that code snippet in a user code module after doing a Report.Failure as well since doing that doesn't automatically abort the code module. But if you have a repository-based failure (could not find element) then it's going to abort the code module. Best to use Teardowns in that case.

Re: Question on latest release notes

Posted: Tue Jul 24, 2012 12:03 am
by carsonw
Ahh ok, yeah that's not useful to us. We need something like this:

Ranorex.Core.Testing.TestCase.Current.Status = Ranorex.Core.Reporting.ActivityStatus.Ignored;

...but not for the whole test case, just the current iteration.

Thanks for taking the time to clarify though.

Re: Question on latest release notes

Posted: Tue Jul 24, 2012 12:56 pm
by Support Team
Hi,

Here is the code which should make the trick.

This code snippet should be located in a Module of your TestCase:
if(iteration>yourLimit)
    ActivityStack.Current.Parent.CustomProperties["ignore"] = "";
You can also rename the property.
Don't forget to add "using Ranorex.Core.Reporting;" to the specific module.

This code snippet should be added to your Program.cs:
[STAThread]
        public static int Main(string[] args)
        {
            Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
            int error = 0;

            TestSuite.TestSuiteCompleted+= new EventHandler(TestSuite_TestSuiteCompleted);
            try
            {
                error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
            }
            catch (Exception e)
            {
                Report.Error("Unexpected exception occurred: " + e.ToString());
                error = -1;
            }
            return error;
        }

        static void TestSuite_TestSuiteCompleted(object sender, EventArgs e)
        {
          ActivityStack.Instance.VisitAll(a => {
                                            if (a.CustomProperties.ContainsKey("ignore"))
                                              a.Status = ActivityStatus.Ignored;
                                            return true;
                                          });
        }
This code will grey out the specific iterations in the report.
I hope this will help you solve the issue.

Regards,
Larissa
Ranorex Support Team

Re: Question on latest release notes

Posted: Fri Jul 27, 2012 6:27 pm
by carsonw
Oh. My. God. This is a HUGE quality of life improvement for us and it works perfectly. It is EXACTLY what we needed. We throw certain types of exceptions in this case so all I had to do was update the code for the exception (and add the event to the program.cs) and now it works for all our tests!

Thank you guys SO much, this is a huge help!

Carson.