Is there a way to get ordered test at runtime?

145 views Asked by At

I have a batch that launches many ordered tests.

During runtime execution, I need to get the name of the current ordered test that is running.

I know how to get current running test info using TestContext class, but it only gives me tests within the ordered test, not the ordered test itself.

So, is there a way to get the current ordered running test informations?

EDIT : Pushing further researchs on the question, I've noticed that even StackTrace doesn't give the name of the ordered test that has invoked its own tests.

So, with "StackFrame(1).GetMethod().Name" I get the name of any parent method that is not an ordered test. When parent method is an ordered test, I only get a generic name "InvokeMethod"...

So strange.

1

There are 1 answers

0
PixelPlex On

BenDev, Any luck with your problem? I know I'm a bit late to the party.I have not tried this myself, so no guaranties.

You could let your batch file write a xml file. In that xml file, you put the ordered test your batch file will call next. Than you make it accessible for your tests by deserializing the file in the code of your tests. Each test could read from that file and convert the data to a simple POCO class.

For completeness, I added some resources that might be useful.

Writing xml from batch file: https://superuser.com/questions/601861/create-an-xml-file-batch

Parsing xml file in c#: https://www.dotnetperls.com/xmlreader