locked
TestRun Information RRS feed

  • Question

  • I'd like to log UnitTest execution information in real time to a database. The difficulty I am coming across is that I cannot tell if a test is being run as part of a larger group such as an OrderedTest. The TestRun class:

    http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.common.testrun.aspx

    Seems to have the information I need, but how do I get a reference to the current TestRun during execution? Is there an easier way to tell if a test is currently being run from within an ordered test? I am quite new to Testing.

    Tuesday, July 8, 2014 8:36 PM

Answers

  • Hello Tina-Shi and Thanks for the reply,

    The database type is SQL. The specific information I would like to record is

    #Tests that were run

    #Pass

    #Fail

    Any error messages that were thrown

    Any messages written to the console during test execution

    Execution Start Time

    Duration of entire execution.

    I have found that a custom DataCollector may be able to be configured to do this. By catching DataCollectionEvents. 

    http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.execution.datacollector.aspx

    http://blogs.microsoft.co.il/shair/2010/04/19/how-to-create-custom-datacollector-in-visual-studio-2010-part-1/

    Thanks again,

    Rjv9645

    Thursday, July 10, 2014 3:07 PM

All replies

  • Hi Rjv9645,

    Could you please tell us what information you want to log unit test to a database? How do you use database? What is the database file type, SQL or others?

    From you message:” Is there an easier way to tell if a test is currently being run from within an ordered test?

    Do you mean that you want to know whether one unit test is running in your ordered test at some point? Or you just want to know whether it has been executed in your ordered test.

    Actually you could get the test results in test explorer windows, I mean that you could get the information about all unit tests’ results in it (passed or failed) if you just want to know if it has been executed.

    https://onedrive.live.com/embed?cid=76DBB449EC93A124&resid=76DBB449EC93A124%21107&authkey=AKW2WOL1hpVtGok

    If you want to log information in test result as part of an ordered test, I find a similar article about how to log information. You can refer to the following link:

    http://blogs.msdn.com/b/gautamg/archive/2009/12/08/logging-a-message-in-test-result-as-part-of-an-automated-test.aspx

    If you want to log information to remind that a test is running within an ordered test, it may need to add custom code in your unit test. For example, a .txt may be as an output file and you save the information into a .txt document.

    About how to make information save into .txt document, reference:

    http://msdn.microsoft.com/en-us/library/8bh11f1k.aspx

    http://msdn.microsoft.com/en-us/library/6ka1wd3w(v=vs.110).aspx

    If I got it wrong, please tell us more detail information about the issue. We will further look at it and provide better solution.

    Best Regards,

    Thursday, July 10, 2014 7:57 AM
  • Hello Tina-Shi and Thanks for the reply,

    The database type is SQL. The specific information I would like to record is

    #Tests that were run

    #Pass

    #Fail

    Any error messages that were thrown

    Any messages written to the console during test execution

    Execution Start Time

    Duration of entire execution.

    I have found that a custom DataCollector may be able to be configured to do this. By catching DataCollectionEvents. 

    http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.execution.datacollector.aspx

    http://blogs.microsoft.co.il/shair/2010/04/19/how-to-create-custom-datacollector-in-visual-studio-2010-part-1/

    Thanks again,

    Rjv9645

    Thursday, July 10, 2014 3:07 PM
  • Hi Rjv9645,

    Form your provide message:

    I have found that a custom DataCollector may be able to be configured to do this. By catching DataCollectionEvents. 

    http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.execution.datacollector.aspx

    http://blogs.microsoft.co.il/shair/2010/04/19/how-to-create-custom-datacollector-in-visual-studio-2010-part-1/

    I think it is a good solution to solve your issue, thanks for you sharing with us the solution. We will mark the thread.

    Best Regards.

    Friday, July 11, 2014 10:25 AM