Page 1 of 1

Disabling reporting

Posted: Wed Dec 08, 2010 9:17 am
by artur_gadomski
Recently I've come across following problem. I needed to disable reporting for one of my test methods used in one context without making changes to it's use in other context. Suppose you have:
public static bool TestMethodA() {
//Doing it's own reporting of debug, info success and failure
}
public static void TestSuiteA() {
    // Ordinary use of test. Use built in reporting
    TestMethodA();
    // other tests
}
public static void TestSuiteB() {
    // Special test suite that needs to handle it's own reporting so that it produces 
    // only one line of test result per run
    bool successSoFar = TestMethodA();
    if (!successSoFar) {
        Report.Failure("Test failed");
    }
    // other tests
    Report.Success("Test passed");
}
I have tried to use Report.End() but it did not seem to work the way I expected. So my solution to this is: use Report.CurrentReportLevel to set reporting to accept reports of a certain level and up. Second part is use of enumeration trick in C# where there are really int's behind it. So:
public static bool TestMethodA() {
//Doing it's own reporting of debug, info success and failure
}
public static void TestSuiteA() {
    // Ordinary use of test. Use built in reporting
    TestMethodA();
    // other tests
}
public static void TestSuiteB() {
    // Special test suite that needs to handle it's own reporting so that it produces 
    // only one line of test result per run

    // This tells reporting to accept nothing.
    Report.CurrentReportLevel = ReportLevel.Failure + 1;
    bool successSoFar = TestMethodA();
    // Restore original reporting
    Report.CurrentReportLevel = ReportLevel.Debug;
    if (!successSoFar) {
        Report.Failure("Test failed");
    }
    // other tests
    Report.Success("Test passed");
}
This works on 2.3.4.I hope Ranorex Team won't break this in future and maybe will think about adding one more enumeration to ReportLevel called None with a highest priority.
Did you ever had a similar problem? How did you solve it?

Re: Disabling reporting

Posted: Fri Dec 10, 2010 2:54 pm
by Support Team
Hello Artur,

Your trick should work fine for all 2.X versions, I will add a ReportLevel.None, which will be in V2.3.6.
For 3.0, you can define custom report levels with custom weights (and custom html style) so you can
define anything you like :)

Michael
Ranorex Team

Re: Disabling reporting

Posted: Fri Mar 04, 2011 11:21 am
by anzacthecat
Hi, can you give us an example of setting custom report levels?

Re: Disabling reporting

Posted: Fri Mar 04, 2011 11:48 am
by Support Team
Hi,

Which version of Ranorex are you using?

Regards,
Peter
Ranorex Team