1 | <!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
---|
2 | <html>
|
---|
3 | <!-- Standard Head Part -->
|
---|
4 | <head>
|
---|
5 | <title>NUnit - VsSupport</title>
|
---|
6 | <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
---|
7 | <meta http-equiv="Content-Language" content="en-US">
|
---|
8 | <link rel="stylesheet" type="text/css" href="nunit.css">
|
---|
9 | <link rel="shortcut icon" href="favicon.ico">
|
---|
10 | </head>
|
---|
11 | <!-- End Standard Head Part -->
|
---|
12 |
|
---|
13 | <body>
|
---|
14 |
|
---|
15 | <!-- Standard Header for NUnit.org -->
|
---|
16 | <div id="header">
|
---|
17 | <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
|
---|
18 | <div id="nav">
|
---|
19 | <a href="http://www.nunit.org">NUnit</a>
|
---|
20 | <a class="active" href="index.html">Documentation</a>
|
---|
21 | </div>
|
---|
22 | </div>
|
---|
23 | <!-- End of Header -->
|
---|
24 |
|
---|
25 | <div id="content">
|
---|
26 |
|
---|
27 | <h2>Visual Studio Support</h2>
|
---|
28 |
|
---|
29 | <p>Visual Studio support in this release is a sort of poor mans integration. We have implemented
|
---|
30 | a number of features while avoiding any that would require using an Addin or otherwise
|
---|
31 | interacting with the Visual Studio extensibility model.</p>
|
---|
32 |
|
---|
33 | <h3>Running From Within Visual Studio</h3>
|
---|
34 |
|
---|
35 | <p>The most convenient way to do this is to set up a custom tool entry specifying the path to
|
---|
36 | NUnit as the command. For a VS2003 C# project, you can use $(TargetPath) for the arguments and
|
---|
37 | $(TargetDir) for the initial directory.
|
---|
38 |
|
---|
39 | <p>With Visual Studio VS2005 this becomes a bit harder, because that release changed the
|
---|
40 | meaning of the 'Target' macros so they now point to the intermediate 'obj' directories rather
|
---|
41 | than the final output in one of the 'bin' directories. Here are some alternatives that
|
---|
42 | work in both versions:
|
---|
43 |
|
---|
44 | <ul>
|
---|
45 | <li><b>$(ProjectDir)$(ProjectFileName)</b> to open the VS Project rather than the assembly.
|
---|
46 | If you use this approach, be sure to rename your config file accordingly and put it
|
---|
47 | in the same directory as the VS project file.
|
---|
48 | <li><b>$(ProjectDir)bin/Debug/$(TargetName)$(TargetExt)</b> to run the assembly directly.
|
---|
49 | Note that this requires hard-coding part of the path, including the configuration.
|
---|
50 | </ul>
|
---|
51 |
|
---|
52 | <p>If you would like to debug your tests, use the Visual Studio
|
---|
53 | Debug | Processes
|
---|
54 | menu item to attach to NUnit after starting it and set breakpoints in
|
---|
55 | your test code as desired before running the tests.</p>
|
---|
56 |
|
---|
57 | <h3>Using Console Interface to Debug Applications</h3>
|
---|
58 |
|
---|
59 | <p>When the nunit-console program is run in debug mode under Visual Studio, it detects that it is
|
---|
60 | running in this mode and sends output to the Visual Studio output window. Output is formatted so
|
---|
61 | that double clicking any error or failure entries opens the appropriate test file at the location
|
---|
62 | where the failure was detected.</p>
|
---|
63 |
|
---|
64 | <h3>Opening Visual Studio Projects</h3>
|
---|
65 |
|
---|
66 | <p>When Visual Studio support is enabled, the File Open dialog displays the following supported
|
---|
67 | Visual Studio project types: C#, VB.Net, J# and C++. The project file is read and the
|
---|
68 | configurations and output assembly locations are identified. Since the project files do not contain
|
---|
69 | information about the most recently opened configuration, the output assembly for the first
|
---|
70 | configuration found (usually Debug) is loaded in the GUI. The tree shows the project as the toplevel
|
---|
71 | node with the assembly shown as its descendant.</p>
|
---|
72 |
|
---|
73 | <p>Beginning with NUnit 2.2.2, you may also open a Visual Studio project by dragging it to the gui tree control.</p>
|
---|
74 |
|
---|
75 | <p>When tests are run for a Visual studio project, they run just as if the output assembly had been
|
---|
76 | loaded with one exception. The default location for the config file is the directory containing the
|
---|
77 | project file and its default name is the same as the project file with an extension of .config.
|
---|
78 | For example, the following command would load the tests in the nunit.tests assembly using the
|
---|
79 | configuration file nunit.tests.dll.config located in the same directory as the dll.
|
---|
80 | <pre class="programtext"> nunit.exe nunit.tests.dll</pre>
|
---|
81 | On the other hand, the following command would load the tests using the configuration file
|
---|
82 | nunit.tests.config located in the same directory as the csproj file.
|
---|
83 | <pre class="programtext"> nunit.exe nunit.tests.csproj</pre>
|
---|
84 | The same consideration applies to running tests using the console runner.</p>
|
---|
85 |
|
---|
86 | <h3>Opening Visual Studio Solutions</h3>
|
---|
87 |
|
---|
88 | <p>When Visual Studio support is enabled, solution files may be opened as well. All the output
|
---|
89 | assemblies from contained projects of the types supported will be loaded in the tree. In the case
|
---|
90 | where all contained projects are located in the subdirectories beneath the solution, it will be
|
---|
91 | possible to load and run tests using this method directly.</p>
|
---|
92 |
|
---|
93 | <p>Beginning with NUnit 2.2.2, you may also open a Visual Studio solution by dragging it to the gui tree control.</p>
|
---|
94 |
|
---|
95 | <p>When a solution contains projects located elsewhere in the file system, it may not be possible to
|
---|
96 | run the tests although the solution will generally load without problem. In this case, the Project
|
---|
97 | Editor should be use to modify and save the NUnit test project so that there is all referenced
|
---|
98 | assemblies are located in or beneath the application base directory.</p>
|
---|
99 |
|
---|
100 | <h3>Adding Visual Studio Projects to the Open Test Project</h3>
|
---|
101 |
|
---|
102 | <p>When Visual Studio support is enabled, the Project menu contains an active entry to add a VS
|
---|
103 | project to the loaded project. The output assembly will be added for each of the configurations
|
---|
104 | specified in the VS project.</p>
|
---|
105 |
|
---|
106 | </div>
|
---|
107 |
|
---|
108 | <!-- Submenu -->
|
---|
109 | <div id="subnav">
|
---|
110 | <ul>
|
---|
111 | <li><a href="index.html">NUnit 2.5.10</a></li>
|
---|
112 | <ul>
|
---|
113 | <li><a href="getStarted.html">Getting Started</a></li>
|
---|
114 | <li><a href="assertions.html">Assertions</a></li>
|
---|
115 | <li><a href="constraintModel.html">Constraints</a></li>
|
---|
116 | <li><a href="attributes.html">Attributes</a></li>
|
---|
117 | <li><a href="runningTests.html">Running Tests</a></li>
|
---|
118 | <ul>
|
---|
119 | <li><a href="nunit-console.html">Console Runner</a></li>
|
---|
120 | <li><a href="nunit-gui.html">Gui Runner</a></li>
|
---|
121 | <li><a href="pnunit.html">PNUnit Runner</a></li>
|
---|
122 | <li><a href="nunit-agent.html">NUnit Agent</a></li>
|
---|
123 | <li><a href="runtimeSelection.html">Runtime Selection</a></li>
|
---|
124 | <li><a href="assemblyIsolation.html">Assembly Isolation</a></li>
|
---|
125 | <li><a href="configFiles.html">Configuration Files</a></li>
|
---|
126 | <li><a href="multiAssembly.html">Multiple Assemblies</a></li>
|
---|
127 | <li id="current"><a href="vsSupport.html">Visual Studio Support</a></li>
|
---|
128 | </ul>
|
---|
129 | <li><a href="extensibility.html">Extensibility</a></li>
|
---|
130 | <li><a href="releaseNotes.html">Release Notes</a></li>
|
---|
131 | <li><a href="samples.html">Samples</a></li>
|
---|
132 | <li><a href="license.html">License</a></li>
|
---|
133 | </ul>
|
---|
134 | </ul>
|
---|
135 | </div>
|
---|
136 | <!-- End of Submenu -->
|
---|
137 |
|
---|
138 |
|
---|
139 | <!-- Standard Footer for NUnit.org -->
|
---|
140 | <div id="footer">
|
---|
141 | Copyright © 2010 Charlie Poole. All Rights Reserved.
|
---|
142 | </div>
|
---|
143 | <!-- End of Footer -->
|
---|
144 |
|
---|
145 | </body>
|
---|
146 | </html>
|
---|