3

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.)

Stephan Bauer
  • 9,120
  • 5
  • 36
  • 58
  • VS is responsible for controlling the test adapters that run the tests, so it may well just get the name of the ordered tests prior to starting up an adapter. I wonder if you can get it through the VS SDK, but that may not help if you are for some reason relying on these names inside the actual test methods that are running? – Smudge202 Oct 10 '12 at 08:43
  • Would that mean that I need to "modify" each VS that should run the tests? I'm afraid that this wonn't be possible... I don't *rely* on the test names, I need them for dynamic log file names - each (ordered) test needs to log to an separate file. Maybe there's even a simpler solution than using the name of the ordered test? – Stephan Bauer Oct 10 '12 at 08:54
  • Hmmm... there is quite a lot you can do with the naming of log files in the test configuration file. Unfortunately I only have VS Pro editions at work so I can't dig into it very well. I wonder though if Ultimate offers a variable that gives you test names and such? Sorry I can't help - best of luck! – Smudge202 Oct 10 '12 at 09:18
  • Hello. Did you find a solution or a workaround since? I'm facing kinf of the same problem as I need to use ordered test as a scenario. Then I wish to know at runtime if The a Test Method is launched from an ordered test so I can put this information in the output Result file... – BenDev Jun 28 '17 at 15:52
  • Or is there any way to pass an argument or to initialise a variable from ordered test to get the information at runtime that it's performing an ordered test and so which one? – BenDev Jun 28 '17 at 16:03

0 Answers0