Unit Testing on build
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?
- Open the Macros IDE (Tools > Macros > Macros IDE).
- Open the EnvironmentEvents module.
- 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
精彩评论