locked
How to capture Test Case ID that's current being run in the MTM in C# test method RRS feed

  • Question

  • Hi All,

    How to capture Current Test Case ID that's current being run in the MTM using C# code

    thanks & Regards,

    woodson 


    • Edited by woodson.gen Wednesday, February 6, 2013 6:26 PM
    Wednesday, February 6, 2013 6:18 PM

All replies

  • Hi Woodson,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 7, 2013 10:22 AM
  • Thanks Amanda.

    I searched in net. found the below mentioned URL. i am not sure this will helpout.

    http://social.msdn.microsoft.com/Forums/pl-PL/vststest/thread/3c22e064-6118-433d-86f6-8990342dd310

    Thanks & Regards,

    Sajan Soosaimichael


    • Edited by woodson.gen Thursday, February 7, 2013 12:35 PM
    Thursday, February 7, 2013 12:34 PM
  • Hi Sajan,

    I didn't test the solution, but various source shows this solution is promising. You will write a custom data collector, and get the executing test case id through TestCaseStartEventArgs.TestCaseId

    Other useful reference:

    1. How to create a custom data collector step by step.
    2. Another similar thread

    best regards,


    Forrest Guo | MSDN Community Support | Feedback to manager

    • Proposed as answer by Forrest Guo Friday, February 8, 2013 2:06 AM
    • Unproposed as answer by woodson.gen Friday, February 8, 2013 5:31 PM
    Friday, February 8, 2013 2:05 AM

  • Thanks for your reply

    I implemented below code to get the current  testcase id. but the ontestcaseStart event is not triggered. could any one pls help me?

    [DataCollectorTypeUri("datacollector://Microsoft/PSRDataCollector/1.0")]
    
    
        [DataCollectorFriendlyName("Test Case Capture")]
        public class TestCaseIDCollector : DataCollector
        {
    
            private DataCollectionEvents dataEvents;
            private DataCollectionLogger dataLogger;
            private DataCollectionSink dataSink;
            private XmlElement configurationSettings;
    
            public override void Initialize(XmlElement configurationElement, DataCollectionEvents events, DataCollectionSink sink,
            DataCollectionLogger logger, DataCollectionEnvironmentContext environmentContext)
            {
                dataEvents = events;  // The test events
                dataEvents.TestCaseStart += new                 EventHandler<TestCaseStartEventArgs>(OnTestCaseStart);
            }
    private void OnTestCaseStart(object sender, TestCaseStartEventArgs e)
            {
    e.TcmInformation.TestCaseId.ToString();
    }
    }

    Friday, February 8, 2013 5:31 PM
  • What's your Visual Studio version? 2010 or 2012? I asked because this API may change between them.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Saturday, February 9, 2013 4:49 AM
  • Thanks for your reply. i am using VS2010

    Now OnTestCaseStart event is trigged in local and the same custom data collector able to see Data diagnostic  tab in localsetting. i copyed the same dll and moved to serve which is integrated with MTM.

    But MTM is not displaying custom data collector to check in data diagnostic . pls tell me i missed any config in MTM to see the custom data collector.


    • Edited by woodson.gen Tuesday, February 12, 2013 7:43 PM
    Tuesday, February 12, 2013 7:43 PM
  • Sorry for the delay. I obseved that Visual Studio & MTM share certain data collector dlls, but there're a few difference. e.g Action Log collector is specific to Test Manager. ASP.NET Profiler collector is specific to Visual Studio. Can you share where you store the collector dll/config, and the configuration file content?

    thanks.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Monday, February 18, 2013 3:06 PM