zoukankan      html  css  js  c++  java
  • 使用mstest.exe 命令行跑test case(不安装Visual Studio 2010)

    怎样在没有安装VS2010的环境里用mstest.exe跑test case?(注:以下实验在64位Windows 7上通过)

    1. 首先在装有VS2010的环境里,新建一个文件夹,如C:UsersusernameDesktopmstestCommandLine(注意文件夹名不能有空格,否则运行下面的脚本会有问题),然后把下面的脚本getmstest.bat复制到此目录下,运行getmstest.bat,这个bat会把mstest.exe需要的类库及注册表都导入到当前目录下一个叫mstest的文件夹里

    getmstest.bat

    复制代码
    @echo off
    setlocal
    set here=%~dp0
    
    mkdir mstest
    set targetfolder=%here%mstest
    
    set programs=%programfiles%
    if exist "%programfiles(x86)%" set programs=%programfiles(x86)%
    set vs2010="%programs%Microsoft Visual Studio 10.0"
    set gac1="%windir%"assembly
    set gac2="%windir%"Microsoft.NETassembly
    
    echo === Copying from Visual Studio 2010 install folder...
    copy %vs2010%Common7IDEmstest* "%targetfolder%"
    copy %vs2010%Common7IDEPrivateAssembliesMicrosoft.VisualStudio.Quality* "%targetfolder%"
    copy %vs2010%Common7IDEPublicAssembliesMicrosoft.VisualStudio.QualityTools.CodedUITestFramework* "%targetfolder%"
    
    echo === Copying from %gac1%...
    pushd "%gac1%"
    dir /s /b *.dll | findstr QualityTools | findstr 10.0.0.0 > %here%tmp.filelist
    popd
    for /F "tokens=*" %%f in (tmp.filelist) DO copy "%%f" "%targetfolder%"
    
    echo === Copying from %gac2%...
    pushd "%gac2%"
    dir /s /b *.dll | findstr QualityTools | findstr 10.0.0.0 > %here%tmp.filelist
    popd
    for /F "tokens=*" %%f in (tmp.filelist) DO copy "%%f" "%targetfolder%"
    
    del tmp.filelist
    
    echo === Exporting registry keys...
    regedit.exe /e %targetfolder%mstest.reg HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0EnterpriseToolsQualityToolsTestTypes
    
    echo === Done. Check output for errors!
    exit /b 0
    复制代码

    2. 准备跑test case需要的文件:我把它们放在了C:UsersusernameDesktopmstestCommandLine est文件夹里,如下图所示。注意下图里的TestResults为自己新建的文件夹,run case时会用到,用于存储test result。现在,要准备的文件都放在了C:UsersusernameDesktopmstestCommandLine里

    3. 在目标机器上安装.NET Framework 4.0
    4. 把C:UsersusernameDesktopmstestCommandLine文件夹复制到目标机器上,假设复制到目标机器的桌面上

    5. 在目标机器上,运行C:UsersusernameDesktopmstestCommandLinemstest这个文件夹里的mstest.reg(双击即可)

    6.在目标机器上,Run->cmd, 回车,进入mstest.exe所在的文件夹,然后运行下面的命令:

    mstest /noisolation /testcontainer:C:Users<username>Desktopmstest	estTestProject1.dll /resultsfile:C:Users<username>Desktopmstest	estTestResults
    esult.trx

    7. 运行结果如下图所示:

    参考:

    http://mindinthewater.blogspot.com/2008/11/executing-visual-studio-unit-tests.html

    http://mindinthewater.blogspot.com/2011/02/executing-visual-studio-2010-unit-tests.html

    出处:https://www.cnblogs.com/jenneyblog/archive/2012/09/14/mstestcommandline.html

    ======================================================================================================

    优化:

    1)可以在任何目录或文件夹下执行

    2)可以直接输出测试报告到文件

    您的资助是我最大的动力!
    金额随意,欢迎来赏!
    款后有任何问题请给我留言。

    如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的推荐按钮。
    如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的关注我。(●'◡'●)

    如果你觉得本篇文章对你有所帮助,请给予我更多的鼓励,求打             付款后有任何问题请给我留言!!!

    因为,我的写作热情也离不开您的肯定支持,感谢您的阅读,我是【Jack_孟】!

  • 相关阅读:
    C++11模板类使用心得
    Linux下MakeFile初探
    Leetcode 35 Search Insert Position 二分查找(二分下标)
    Leetcode 4 Median of Two Sorted Arrays 二分查找(二分答案+二分下标)
    数据库分库分表的应用场景及方法分析
    DB主从一致性的几种解决方法
    Redis主从复制和集群配置
    RPC vs RESTful
    Mysql锁详解
    BIO与NIO、AIO的区别
  • 原文地址:https://www.cnblogs.com/mq0036/p/13255662.html
Copyright © 2011-2022 走看看