none
How to run MSTest.exe from batch file by identifying the current framework installed. RRS feed

  • Question

  • Hi Team,

    I have a Microsoft Unit Test Framework dll, I want to run unit test cases and generate results using MSTest.exe 

    I have .net framework 3.5 installed, from Visual Studio Command Prompt I am able to run MSTest.exe and getting the output results.  However I want to run MSTest.exe from .bat (batch file).  Find my code below:

    if exist "%WINDIR%\Microsoft.Net\Framework\v3.5" (
    call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
    MSTest /testcontainer:Com.Taxware.NUnitTest.dll
    )
    if NOT exist "%WINDIR%\Microsoft.Net\Framework\v3.5" (
    echo Please install .Net Framework3.5 to run Unit Test Cases
    )
    pause
    

    Here the problem is if client has .Net Framework 4.0 or 4.5, 5.0 or later, this script will fail.  I want some generic solution to run my Uni Test Framework dll in any framework.   How can I achieve this, please help!!

    Wednesday, September 11, 2013 12:39 PM

Answers

All replies

  • <copied>

    I have a Microsoft Unit Test Framework dll, I want to run unit test cases and generate results using MSTest.exe 

    <end>

    What's the purpose of this, since the .Net solution should have a Unit Test project, and a build machine should be running all unit test when code is checked into to TFS as an example?

    Wednesday, September 11, 2013 1:01 PM
  • I don't have TFS to run these Uni Test Cases. 

    As per the requirements, just a batch file should run these unit test cases whenever they want to run. 

    One more scenario may also arise: There is no .Net Framework3.5 SDK installed in client machine.  So I don't have Visual Studio Command Prompt or MSTest.exe at all.  In that cases how can I run these Unit Test Cases.    When I search for it I found like Visual Studio 2010 agents, using them I can run these test cases.  Can anyone help me how to run my dll using Visual Studio 2010 agents?

    Give me answer to either of my questions, that will help me. 

    Wednesday, September 11, 2013 1:14 PM
  • <copied>

    I don't have TFS to run these Uni Test Cases. 

    <end>

    http://www.microsoft.com/visualstudio/eng/products/visual-studio-team-foundation-server-express

    I use it with VS2010, which you need to download fix to make it work with TFS Express.

    I use 2012 Express Edition for C# desktop to set up TFS projects.

    I have not gotten into Team Builds with Unit Tests, although I have TFS Build Notification setting in tasktrey. I don't even know why that showed up. :)

    • Marked as answer by Eason_H Wednesday, September 18, 2013 1:08 AM
    Wednesday, September 11, 2013 2:03 PM