Question on latest release notes

Ranorex Spy, Recorder, and Studio.
carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Question on latest release notes

Post by carsonw » Tue Jul 17, 2012 5:37 pm

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 :)

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Question on latest release notes

Post by Support Team » Wed Jul 18, 2012 2:37 pm

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
.
Image

GeosoftRep
Posts: 6
Joined: Thu May 17, 2012 1:50 pm

Re: Question on latest release notes

Post by GeosoftRep » Wed Jul 18, 2012 4:23 pm

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

carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Re: Question on latest release notes

Post by carsonw » Wed Jul 18, 2012 11:07 pm

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.

GeosoftRep
Posts: 6
Joined: Thu May 17, 2012 1:50 pm

Re: Question on latest release notes

Post by GeosoftRep » Thu Jul 19, 2012 8:32 pm

  • 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.

carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Re: Question on latest release notes

Post by carsonw » Tue Jul 24, 2012 12:03 am

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Question on latest release notes

Post by Support Team » Tue Jul 24, 2012 12:56 pm

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
.
Image

carsonw
Posts: 178
Joined: Tue Nov 08, 2011 10:01 pm

Re: Question on latest release notes

Post by carsonw » Fri Jul 27, 2012 6:27 pm

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.