Feature Request: Setup and Teardown sections in report

Bug reports.
User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Feature Request: Setup and Teardown sections in report

Post by artur_gadomski » Fri Nov 09, 2012 12:48 pm

Hi
As an automator using Ranorex API I would like the Ranorex Report and Report class to have ability to specify Setup and Teardown sections for Test Cases that are hidden or have smaller visibility impact on whole report, so that I can create reports with greater readability.

We use Ranorex to develop keyword driven tests where each keyword is a module in report. Each test case is a test case in report and consists of a bunch of keywords. For each test case there is a setup and teardown consisting of keywords. These go as modules under each test case in report, mixing with keywords from tests. Each suite has setup and teardown consisting of keywords. These go as modules outside of Test Cases further decreasing readability.

I would like to say Report.BeginSetup() and all modules until I write Report.EndSetup() would be grouped together in a hidden(with ability to show) or small and grey section. I imagine it should be able to expand and collapse this section and font would be smaller than module and color would be gray. Similar functionality should work for Teardown. These sections should like modules be allowed on suite and test case level. So I should be allowed to have structure as follows:

Code: Select all

Suite
|_Setup
|_Module
|_TestCase
   |_Setup
   |_Module
   |_Teardown
|_Teardown
|_Setup
|_TestCase
   |_Module
|_Teardown
I'm attaching a sample report from one of our tests, without screenshot that illustrates our problem.
Attachments
Report.rar
Sample Report
(127.16 KiB) Downloaded 295 times

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

Re: Feature Request: Setup and Teardown sections in report

Post by Support Team » Fri Nov 09, 2012 4:25 pm

Hi,

If I got you correctly this can be already done.
You can use the following code in order to define a setup/teardown region in code:
using(new ActivityContext(new TestModuleContainerActivity(ModuleExecType.Setup))){ // OR: ModuleExecType.Teardown
            TestReport.BeginTestModule("Recording2");
            TestModuleRunner.Run(rec);

            TestReport.EndTestModule();
            }
If you want that a section should be marked as ignored (grayed out) you could add the following code right after you end the test report:
ActivityStack.Instance.VisitAll(a =>
            {
                if (a.CustomProperties.ContainsKey("ignore"))
                    a.Status = ActivityStatus.Ignored;
                return true;
            });
In the Module which is in the section which should be marked as ignored you have to set this custom property to "ignore":
ActivityStack.Current.Parent.CustomProperties["ignore"] = "";
don't forget to add "using Ranorex.Core.Reporting;" to that module.

Regards,
Markus
.
Image

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Feature Request: Setup and Teardown sections in report

Post by artur_gadomski » Mon Nov 12, 2012 3:02 pm

Great. It would be nice if this feature was documented and wrappers like BeginTestCase etc were created.
Also using this code:
TestReport.Setup(ReportLevel.Debug, "Report.rxlog", true);
TestReport.BeginTestSuite("Suite");
using (new ActivityContext(new TestModuleContainerActivity(ModuleExecType.Setup)))
{
    TestReport.BeginTestModule("Setup 1");
    Report.Info("Bla");
    Report.Failure("Failed.");
    TestReport.EndTestModule();
}
A report with hidden failures is created. Setup part looks passed even though module under it fails. See attached BrokenReport.

As I my setup and teardown span accross multiple methods I needed to create begin and end setup methods anyway. Here are my wrappers for Setup and Teardown that also eliminate above mentioned problem (see attached GoodReport).
private static ActivityContext setup;
private static ActivityContext teardown;
public static void BeginSetup()
{
    CloseActivity(ref setup);
    CloseActivity(ref teardown);
    setup = new ActivityContext(new TestModuleContainerActivity(ModuleExecType.Setup));
}

public static void BeginTeardown()
{
    CloseActivity(ref setup);
    CloseActivity(ref teardown);
    teardown = new ActivityContext(new TestModuleContainerActivity(ModuleExecType.Teardown));
}

public static void EndSetup()
{
    CloseActivity(ref setup);
}

public static void EndTeardown()
{
     CloseActivity(ref teardown);
}

private static void CloseActivity(ref ActivityContext activity)
{
     if (activity != null)
     {
          ActivityStack.Current.VisitChildren(a =>
                {
                    if (a.Status == ActivityStatus.Failed)
                    {
                        ActivityStack.Current.Status = ActivityStatus.Failed;
                    }
                    return true;
                });
          TestReport.EndTestModule();
          activity = null;
      }
}

[STAThread]
public static int Main(string[] args)
{
    TestReport.Setup(ReportLevel.Debug, "Report.rxlog", true);
    TestReport.BeginTestSuite("Suite");
    BeginSetup();
    TestReport.BeginTestModule("Setup 1");
    Report.Info("Bla");
    Report.Failure("Failed.");
    TestReport.EndTestModule();
    EndSetup();
    return 0;
}
Attachments
GoodReport.rar
Good Report
(119.38 KiB) Downloaded 235 times
BrokenReport.rar
Broken Report
(119.38 KiB) Downloaded 269 times

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

Re: Feature Request: Setup and Teardown sections in report

Post by Support Team » Tue Nov 13, 2012 5:44 pm

Hi,

That's true!
I already added an issue for this feature request. There will be methods which allow you to define setup and teardown regions in code. This feature will be added in one of our next releases.

Regards,
Markus
.
Image

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Feature Request: Setup and Teardown sections in report

Post by artur_gadomski » Thu Nov 15, 2012 11:03 am

If possible can you make it so that calling EndSetup will end setup activity if it's there and not do anything if it's not. Same for teardown.
We can be certain to start setup and teardown but if something goes wrong during our setup we won't be able to call End Setup. So I'd like to put End Setup method call also when trying to start TestCase and Start teardown in our keyword wrappers (just like in my code example above).

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

Re: Feature Request: Setup and Teardown sections in report

Post by Support Team » Fri Nov 16, 2012 12:03 pm

Hi,

Thanks for the suggestion!
We will bear that in mind.

Regards,
Markus
.
Image

c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Re: Feature Request: Setup and Teardown sections in report

Post by c676228 » Sat Sep 19, 2015 12:35 am

I am not familiar with the classes used here at all.
Are TestModuleContainerActivity and ActivityStack developed by yourself? I don't see it in the Ranorex API.

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

Re: Feature Request: Setup and Teardown sections in report

Post by Support Team » Mon Sep 21, 2015 3:56 pm

Hi,

Yes, it was developed by us. The ActivityStack is simply a stack where the execution information of the test is stored. The ActivityStack is used for creating the Ranorex report.

This is quite an old thread, and the requested feature is already part of the TestReport class:TestReport Class.

Regards,
Markus
.
Image