<p><img src="https://i.stack.imgur.com/DibJS.jpg" alt="Visual Studio folder structure"></p>

<p>I need some advice as to how I easily can separate test runs for unit tests and integration test in Visual Studio. Often, or always, I structure the solution as presented in the above picture: separate projects for unit tests and integration tests. The unit tests is run very frequently while the integration tests naturally is run when the context is correctly aligned.</p>

<p>My goal is to somehow be able configure which tests (or test folders) to run when I use a keyboard shortcut. The tests should preferably be run by a graphical test runner (ReSharpers). So for example</p>

<ul>
<li>Alt+1 runs the tests in project BLL.Test, </li>
<li>Alt+2 runs the tests in project DAL.Tests, </li>
<li>Alt+3 runs them both (i.e. all the tests in the [Tests] folder, and</li>
<li>Alt+4 runs the tests in folder [Tests.Integration].</li>
</ul>

<p>TestDriven.net have an option of running just the test in the selected folder or project by right-clicking it and select Run Test(s). Being able to do this, but via a keyboard command and with a graphical test runner would be awesome.</p>

<p><img src="https://i.stack.imgur.com/NYnmJ.jpg" alt="TestDriven.net test run output"></p>

<p>Currently I use VS2008, ReSharper 4 and nUnit. But advice for a setup in the general is of course also appreciated.</p>

[{'answer_id': 13953, 'author': 'Wilka', 'author_id': 1367, 'author_profile': 'https://Stackoverflow.com/users/1367', 'pm_score': 0, 'selected': False, 'text': '<p>This is a bit of fiddly solution, but you could configure some <a href="http://blogs.msdn.com/saraford/archive/2008/04/24/did-you-know-you-can-run-external-tools-within-visual-studio-201.aspx" rel="nofollow noreferrer">external tools</a> for each of group of tests you want to run. I\'m not sure if you\'ll be able to launch the ReSharper test runner this way, but you can run the console version of nunit. Once you have of those tools setup, you can assigned keyboard shortcuts to the commands "Tools.ExternalCommand1", "Tools.ExternalCommand2", etc.</p>\n\n<p>This wont really scale very well, and it\'s awkward to change - but it will give you keyboard shortcuts for running your tests. It does feel like there should be a much simpler way of doing this.</p>\n'}, {'answer_id': 13969, 'author': 'andynil', 'author_id': 446, 'author_profile': 'https://Stackoverflow.com/users/446', 'pm_score': 3, 'selected': True, 'text': '<p>I actually found kind of a solution for this on my own by using keyboard command bound to a macro. The macro was recorded from the menu Tools>Macros>Record TemporaryMacro. While recording I selected my [Tests] folder and ran ReSharpers UnitTest.ContextRun. This resulted in the following macro, </p>\n\n<pre><code>Sub TemporaryMacro()\n    DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate\n    DTE.ActiveWindow.Object.GetItem("TestUnitTest\\Tests").Select(vsUISelectionType.vsUISelectionTypeSelect)\n    DTE.ExecuteCommand("ReSharper.UnitTest_ContextRun")\nEnd Sub\n</code></pre>\n\n<p>which was then bound to it\'s own keyboard command in Tools>Options>Environment>Keyboard.</p>\n\n<p>However, what would be even more awesome is a more general solution where I can configure exactly which projects/folders/classes to run and when. For example by the means of an xml file. This could then easily be checked in to version control and distributed to everyone who works with the project.</p>\n'}, {'answer_id': 14090, 'author': 'Mark Cidade', 'author_id': 1659, 'author_profile': 'https://Stackoverflow.com/users/1659', 'pm_score': 0, 'selected': False, 'text': '<p>You can use a VS macro to parse the XML file and then call nunit.exe with the /fixture command line argument to specify which classes to run or generate a selection save file and run nunit using that.</p>\n'}, {'answer_id': 25640, 'author': 'Gern Blanston', 'author_id': 2786, 'author_profile': 'https://Stackoverflow.com/users/2786', 'pm_score': 0, 'selected': False, 'text': '<p>I have never used this but maybe it could help....</p>\n\n<p><a href="http://www.codeplex.com/VS2008UnitTestGUI" rel="nofollow noreferrer">http://www.codeplex.com/VS2008UnitTestGUI</a></p>\n\n<p>"Project Description\nThis project is about running all unit test inside multiple .NET Unit tests assembly coded with Visual Studio 2008."</p>\n'}]
['https://Stackoverflow.com/questions/13938', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/446/']