【问题标题】:Unit Testing on build构建单元测试
【发布时间】:2011-02-05 06:12:53
【问题描述】:

有更好的方法吗?我使用了 Visual Studio Gallery 中的 Continuous Testing AddIn,但不适用于 SolutionFolders..

所以我只是用

添加了一个“构建后宏”

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /testcontainer:"$(TargetPath)"

效果很好,但是当出现错误时,我得到的只是一个退出代码,有没有更好的方法来做到这一点?

【问题讨论】:

    标签: visual-studio unit-testing testing


    【解决方案1】:
    1. 打开宏 IDE(工具 > 宏 > 宏 IDE)。
    2. 打开 EnvironmentEvents 模块。
    3. 添加此代码:

    .

    Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone
        RunTests()
    End Sub
    
    Private Sub RunTests()
        ' Only run tests if there were no errors during build. 
        If (DTE.ToolWindows.ErrorList.ErrorItems.Count = 0) Then
            ' MSTest
            DTE.ExecuteCommand("Test.RunAllTestsInSolution")
            ' ReSharper
            'DTE.ExecuteCommand("ReSharper.ReSharper_UnitTest_RunSolution")
        End If
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-15
      • 1970-01-01
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      • 2015-07-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多