Getting CurrentTestContainer ReportLevel

Class library usage, coding and language questions.
cpalex
Posts: 38
Joined: Sat Feb 17, 2018 12:37 am

Getting CurrentTestContainer ReportLevel

Post by cpalex » Mon May 18, 2020 5:54 pm

I have some code I would like to run, only if the current report level is Debug.

I can use the current test suite debug level in the TestSuite.Current.ReportLevel, but since each container or test case can have a level other than Inherit, I need to know the actual report level of the test container.

While debugging, I can see the local variable of ReportLevel for the TestSuite.Current.CurrentTestContainer, but I cannot actually use it in code

What would be the proper way to tell what the current report level was?

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Getting CurrentTestContainer ReportLevel

Post by Stub » Tue May 19, 2020 8:20 am

What do you mean by, "I cannot actually use it in code"?

If it's "Inherit" can you recurse up the ParentContainer hierarchy until you find the report level it's inheriting?

cpalex
Posts: 38
Joined: Sat Feb 17, 2018 12:37 am

Re: Getting CurrentTestContainer ReportLevel

Post by cpalex » Mon Aug 17, 2020 5:57 pm

When I say that I cannot use it in code, I can see it while debugging, but don't know how to actually USE it in my user code logic.

Forgive me if it is simple code, I am not a programmer, just a tester who was thrown deep into user code.

I just basically need this

Code: Select all

if (ReportLevel == Debug)
{
	do this;
}
But of course, that doesn't actually work.

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Getting CurrentTestContainer ReportLevel

Post by Stub » Tue Aug 18, 2020 8:21 am

I still don't really understand what you're asking for I'm afraid.

You could write a code module that acquires the current Test Container report level and assigns that to a Parameter on the Test Case. You could then put conditions onto your Smart Folders such that they only execute if this previously acquired report level is such-and-such, thus controlling which modules or recordings run.

But I really don't know if that's what you're trying to do.