NUnit From VS

Last week I found the best VS+NUnit add in I know until now: https://www.mailframe.net/Products/TestRunner.htm

It works great, however I got some errors related to the credentials of the process running your test fixtures (I was trying to find a certificate in the User Store, running the TestSuite from VS AddIn points to a different store that when you run the tests from the original NUnit)

So I keep my old macro to configure the VS Project to be launched from NUnit. (here is the VB Macro for VS.NET)

 

Imports System

Imports EnvDTE

Imports System.Diagnostics

Imports VSLangProj

#Region "Path to NUnit"

Public Module NUnitConstants

    Public Const BASE_PATH As String = "c:\Program Files\NUnit v2.1\bin\"

    Public Const NUNIT_FX As String = BASE_PATH & "nunit.framework.dll"

    Public Const NUNITGUI_RUNNER As String = BASE_PATH & "nunit-gui.exe"

End Module

#End Region

Public Module TestProjectConfigurator

    Dim currentProject As VSProject

#Region "Private"

    Private Sub addReference(ByVal referencePath As String)

        currentProject.References.Add(referencePath)

    End Sub

    Private Sub setDebugProperties(ByVal runnerPath As String)

        Dim assemblyName As EnvDTE.Property = CType(currentProject.Project.Properties.Item("AssemblyName"), EnvDTE.Property)

        Dim configProps As Properties = currentProject.Project.ConfigurationManager.ActiveConfiguration.Properties

        With configProps

            .Item("StartAction").Value = prjStartAction.prjStartActionProgram

       .Item("StartProgram").Value = runnerPath

            .Item("StartArguments").Value = assemblyName.Value + ".dll"

        End With

    End Sub

    Private Sub setBuildEvents()

        Dim configProps As Properties = currentProject.Project.Properties

        Dim appConfigCmd = "copy ""$(ProjectDir)App.config"" ""$(TargetDir)$(TargetFileName).config"""

      

        With configProps

            .Item("PreBuildEvent").Value = appConfigCmd

        End With

    End Sub

    Private Sub configureProject()

        addReference(NUNIT_FX)

        setDebugProperties(NUNITGUI_RUNNER)

        setBuildEvents()

    End Sub

#End Region

    Public Sub Run()

        currentProject = DTE.ActiveSolutionProjects(0).Object

        configureProject()

    End Sub

    Public Sub ResetConfig(ByVal nada As Object)

        currentProject = DTE.ActiveSolutionProjects(0).Object

    End Sub

End Module