开发者

Unit Testing on build

开发者 https://www.devze.com 2023-01-14 08:18 出处:网络
Any better way to do this? I\'ve used the Continuous Testing AddIn from visual studio gallery, but does not work with SolutionFolders..

Any better way to do this? I've used the Continuous Testing AddIn from visual studio gallery, but does not work with SolutionFolders..

so I just added a "Post Build Macro" with

"C:\Pr开发者_如何转开发ogram Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /testcontainer:"$(TargetPath)"

Works great, but when there are errors, all I get is an exit code, is there a better way to do this?


  1. Open the Macros IDE (Tools > Macros > Macros IDE).
  2. Open the EnvironmentEvents module.
  3. Add this code:

.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消