locked
Read arguments supplied in mstest.exe command RRS feed

  • Question

  • Hi,

    Within my code, I would like to get the TestCategory name supplied to mstest.exe, in order to perform specific logic to each of my TestMethods.  The command line arguments must be stored within the unit test framework...just can't figure out where.

    Any ideas would be very helpful:)


    Thanks!!

    Thursday, November 11, 2010 8:41 PM

Answers

  • Hi,

    You can use reflection to get the TestCategory of your TestMethods using

    object obj = GetType().GetMethod(testCaseName).GetCustomAttributes(typeof(Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute), false);
    string category = ((TestCategoryAttribute)obj).TestCategory;

    Thanks,

    Anuj

    Friday, November 12, 2010 12:20 AM