If my Test Suite has Report Level set to Warn (using the Right-Click menu), can I over-ride this setting in one of my Test Cases in code - for the rest of the Test Suite.
Report.CurrentReportLevel gets or sets the Current Report Level, and I have tried to do this by setting it to ReportLevel.Info in the Program.cs before running the TestSuiteRunner, but the setting does not persist.
The next Test case Continues with CurrentReportLevel=Warn.
How can I set this level & make it persist for the whole Test Suite?
Report Level - can I over ride in code?
Re: Report Level - can I over ride in code?
You will have to do it INSIDE TestSuiteRunner. When TestSuiteRunner is started, it will overwrite anything you assigned outside of it.
This means you will need to create a module that does what you want and then drop it into the SETUP section of the test suite.
You could then drop it anywhere else you need it, and even data-drive it so you can change the report level using data.
This means you will need to create a module that does what you want and then drop it into the SETUP section of the test suite.
You could then drop it anywhere else you need it, and even data-drive it so you can change the report level using data.
Shortcuts usually aren't...
Re: Report Level - can I over ride in code?
I have done some experiments, and it is a lot more complicated than that.
It reverts to the Test Suite default at the beginning of each Test Case.
It reverts to the Test Suite default at the beginning of each Test Case.
Re: Report Level - can I over ride in code?
Ah, I didn't know that either. Ouch.
I guess you could still do it this way, and just drop the module in the SETUP section for each test case? But that creates more stuff to manage... :S
I guess you could still do it this way, and just drop the module in the SETUP section for each test case? But that creates more stuff to manage... :S
Shortcuts usually aren't...
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: Report Level - can I over ride in code?
Hi guys,
I guess this is possible with the following lines of code:
Hope this helps.
Cheers,
Robin
I guess this is possible with the following lines of code:
var ts = TestSuite.Current; var tc1 = (TestCase) ts.GetTestCase("TestCase"); tc1.ReportLevel = ReportLevel.Failure;So you can set the report level even of multiple test cases in advance.
Hope this helps.
Cheers,
Robin
Re: Report Level - can I over ride in code?
This works:
Code: Select all
/// <summary>
/// sets the Current Report Level to the Global value from Run Parameter
/// </summary>
public static void SetReportLevel()
{
// get
string before=Report.CurrentReportLevel.ToString();
Report.Info ("Get Level = " + before);
// set
Report.CurrentReportLevel=GlobalLevel ;
Report.Info ("Set Level = " + Report.CurrentReportLevel.ToString ());
}