How to get the name of the currently executing OrderedTest

365 views Asked by At

I have some ordered tests containing test methods. Some test methods are used in multiple ordered tests.

<?xml version="1.0" encoding="UTF-8"?>
<OrderedTest name="orderedtest_A" ...>
  ...
  <TestLinks>
    <TestLink id="..." name="testmethod_A" ... />
    <TestLink id="..." name="testmethod_B" ... />
    <TestLink id="..." name="testmethod_G" ... />
    <TestLink id="..." name="testmethod_Z" ... />
  </TestLinks>
</OrderedTest>

and

<?xml version="1.0" encoding="UTF-8"?>
<OrderedTest name="orderedtest_B" ...>
  ...
  <TestLinks>
    <TestLink id="..." name="testmethod_A" ... />
    <TestLink id="..." name="testmethod_M" ... />
    <TestLink id="..." name="testmethod_E" ... />
  </TestLinks>
</OrderedTest>

As you can see, testmethod_A is used in orderedtest_A and in orderedtest_B At execution time, I need to get the name of the ordered test that is currently running, e.g. orderedtest_B.

I know that I can get the name of currently running test mehod by reading the TestContext.TestName property (e.g. testmethod_B)

This would be fine if each test method was only used in one ordered test (then I could read all *.orderedtest xml-files and search for the test method with the given name) - but this is not the case! (as described above: see testmethod_A)

In VS2010, the name of the ordered test is used quite often:

  • In the test list editor
  • In the test results list
  • In the test view

So maybe there is a possibility to read the name of the ordered test but is there also a way to get it at runtime?

(BTW - To be exact, I want the name of the test as it is shown in the test results list.)

0

There are 0 answers