locked
How to run unit tests programmatically?

    Question

  • Can anyone point me to some documentation and/or examples of how to run unit tests programmaticaly (e.g. using the testing object model)?  I realize I can use MSTest to run tests, but I'd like to be able to kick them off and retrieve the results programmatically using the testing object model.

     

    Tuesday, June 19, 2007 7:49 PM

Answers

  • I wouldn't say there is no way to run them programmatically.  There is always a way to get to the internal methods of an assembly through reflection.  As far as I know, TestDriven.NET are not using the VSTT object model to run tests.  They have integrated into VS and have provided there own framework, object model and attributes (as you can see in the screenshots) that is different from VSTT.  I assume they generate their own results and results file.

     

    MS Test is able to run a specific test by using the /test switch, but TestDriven.NET does not use mstest, or VSTT object model.

     

    Thanks

     

     

    Thursday, June 21, 2007 4:30 PM

All replies

  • There isn't any way to get programmatically at the Test Results.  The Test Results are stored in memory until the run finishes, at which time it is serialized to the disk.

     

    There isn't any way to run them programmatically either.

     

    Wednesday, June 20, 2007 3:49 PM
  • Bruce,

     

    Thanks for the reply.  Just so I understand - you say there is no way to run them programmatically.  So, does that imply that certain Visual Studio Add-Ins (e.g. TestDriven.NET) are running the unit tests via MSTest?  The TestDriven.NET add-in has the ability to run a single test method (e.g. if you right-click within a test method's source code and select "Run Test(s)") - is this an ability of MSTest?  Or, does the Visual Studio SDK allow add-ins to manipulate unit tests via the object model?

     

    Wednesday, June 20, 2007 3:56 PM
  • I wouldn't say there is no way to run them programmatically.  There is always a way to get to the internal methods of an assembly through reflection.  As far as I know, TestDriven.NET are not using the VSTT object model to run tests.  They have integrated into VS and have provided there own framework, object model and attributes (as you can see in the screenshots) that is different from VSTT.  I assume they generate their own results and results file.

     

    MS Test is able to run a specific test by using the /test switch, but TestDriven.NET does not use mstest, or VSTT object model.

     

    Thanks

     

     

    Thursday, June 21, 2007 4:30 PM
  • Thanks for the clarification.  After further digging, I realized that TestDriven.NET attempts to use several non-Microsoft tools to run the tests (e.g. MbUnit, NUnit, etc.).  The include various distributions of 3rd party test tools with their installation in order to run the tests.

     

    Thursday, June 21, 2007 6:31 PM
  • Were you able to run the unit tests programmatically?

    If so, how?

     

    Thanks

    Wednesday, May 28, 2008 2:15 PM