0

I'm trying to retrieve a list of the selected test to run in ClassInitialize. Can you help with that?

[ClassInitialize]
public void classInitialize()
{
    String name=TestContext.CurrentContext.Test.MethodName;
}

Using the above code I'm able to get only the current running test cases.

[ClassInitialize]
public void ClassInitialize()
{
    //Need to get the list of the selected test to run.
}

Actual: I'm unable to retrieve selected tests.

Expected: Should list of the list of test to run.

natn2323
  • 1,983
  • 1
  • 13
  • 30
Vijaya s
  • 31
  • 5
  • Why do you need that? It was already asked here: https://stackoverflow.com/q/17715850/7225096 – Peska Jul 11 '19 at 13:58
  • I have list of pre-requite based on test case(currently used reflection and if method name found in SWITCH case, I will execute that case..But in my case if I try to run a single test method .. it will take all the test methods in assembly and execute all the pre-requisite to avoid that I need this) and that needs to executed before calling actual test methods. If i know the test name i can Already asked question is to take all the methods in running assembly. – Vijaya s Jul 12 '19 at 07:28
  • Based on your latest comment, why not use [MSTest Categories](https://learn.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests) to organize your test cases and set them up based on the category they are in? – natn2323 Jul 17 '19 at 05:39

0 Answers0