locked
Create a TRX file whenever any tests are executed from Test Explorer RRS feed

  • Question

  • Hi

    Has anyone written or have any clue on how to have a TRX (Test Results) file be created whenever tests are executed from Test Explorer?

    The main issue im having is that the tests run a SQL statement against a database and I need to know how long it took to run that SQL. Running the tests in Test Explorer is great but im unable to get the results out of Visual Studio into my Report.

    I do know that the tests can be run from Command Prompt, but this does not give me the flexibility I get when running multiple Selected Tests in Test Explorer. This is why I need a TRX file generated so that I can get the results into Excel

    Im using Visual Studio 2012 Ultimate


    Monday, July 1, 2013 10:20 PM

Answers

All replies

  • How would a TRX file help you to generate the report you need?
    Monday, July 1, 2013 10:36 PM
  • How would a TRX file help you to generate the report you need?

    When you open a TRX file in Visual Studio 2012 It opens inside the Test Results pane as columns and rows. With this you can now select multiple rows or right click and choose Select All. By copying the selected rows you are now able to paste this inside Excel reports in a format of columns and rows that is consistent between test runs and no further editing is required.

    With Test Explorer you can only copy one row at a time, and pasting this row into Excel results in a format that requires much to much editing to realign the rows into columns.

    Is this answer satisfactory?

    Monday, July 1, 2013 11:15 PM
  • On trying to find a solution to this in code I had a look at the TestContext.AddResultFile() method

    But as it turns out no TRX file is created, instead the file you specified in the parameters is now included in the results displayed in Test Explorer and these results are still unusable as far as my initial requirements are concerned.

    So far I see no API that allows you to write C# code that instructs MSTest framework to create TRX results file.

    or am I missing something?

    Tuesday, July 2, 2013 10:12 PM
  • My next attempt was to investigate if there was something available in the settings files that I could 'switch on' in order for the test run to produce a TRX file.

    I have also had a look at the .testsettings and .runsettings options and there appears to be no joy there either

    These are the URL's where I got information from

    Configuring Unit Tests by using a .runsettings File

    http://msdn.microsoft.com/en-us/library/vstudio/jj635153.aspx#example

    and

    Specifying Test Settings for Visual Studio Tests

    http://msdn.microsoft.com/en-us/library/vstudio/ee256991.aspx

    The .testsettings options have a Data and Diagnostics section which looked promising, but in the end the Test Explorer does not provide a way to export anything!

    Tuesday, July 2, 2013 10:20 PM
  • I seem to have found a way of getting results that I can use into Excel.

    In VS2012 you can create a Load Test module and include Unit Test as part of the Test Mix.

    By running this Load Test the results it produces can be exported to Excel

    I got a lot of information from the following URL's

    Walkthrough: Creating and Running a Load Test Containing Unit Tests

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

    Emulating Expected Real-World Usage of a Web Site or Application in a Load Test Using a Test Mix Models

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

    Wednesday, July 3, 2013 2:21 AM
  • Hello,

    Glad to see this issue has been resolved and thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions.

    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.

    Wednesday, July 3, 2013 4:27 AM
  • Thanks for sharing this. Would you mind elaborating on the purpose of this report? What end result does it have to accomplish? How do you use the report? How often do you prepare it.

    Wednesday, July 3, 2013 2:37 PM
  • Thanks for sharing this. Would you mind elaborating on the purpose of this report? What end result does it have to accomplish? How do you use the report? How often do you prepare it.

    Yeah sure no problem.

    Would you mind elaborating on the purpose of this report?

    The purpose of this report is to inform Managers, Team Leads, DBA's and other project stakeholders of performance degradations in our DB2 databases as software development teams produce more product features.

    What end result does it have to accomplish?

    As our company has limited Continuous Integration(CI) capabilities the end result of this report allows decisions to be made around the feasibility of feature rework due to poor DB2 performance.

    How do you use the report?

    Currently we are implementing a SharePoint solution so the report will be published to a Team Site as an Excel Spreadsheet. I believe, in SharePoint, this Excel Charts can be  presented on a Page.

    How often do you prepare it?

    At the moment the decision as to 'How often it will be prepared' has not be finalised yet, but if we consider that the tests are to measure Performance and Load then the best time to do this, in our situation', will be at the end of either an Agile Iteration, the completion of a feature or because support is reporting that Users are experiencing a lag in the returning of data

    Wednesday, July 3, 2013 9:24 PM