Brent Strange's thoughts on Software Quality Assurance and technology
| |
|
|
| |
Have you ever been in the position where you want to convert an already existing Visual Studio 2005 project to be a Test Project so that you can write and run unit tests? There is no simple way, but there is a hack.
Assuming that you are using a version of Visual Studio that supports Testing (e.g. Team Edition for Software Testers) here is how to do it:
- Add the following .NET Reference to the project:
Microsoft.VisualStudio.QualityTools.UnitTestFramework
- Put in the following using directive in the .cs file that contains your tests:
using Microsoft.VisualStudio.TestTools.UnitTesting;
- Create a Test List, this will generate the .vsmdi file (This is the file that opens your Test Manager tab):
- Click Test in the top menu
- Select Create New Test List:
- Notice in the Solution Explorer that the Project now is wrapped in a Solution and the .vsmdi file has been created:

- Setup your test configuration file (.testrunconfig):
- In Solution Explorer right click the Solution Items folder, select Add, then select New Item
- In the dialog, highlight Test Run Configuration on the left and select Test Run Configuration on the right side
- Name the file accordingly and then click Add:
- Notice the .testrunconfig file has been added to the solution
- Close Visual Studio
- Open the project's .csproj file in a text editor.
- In the top <PropertyGroup> node, change the <ProjectTypeGuids> node to read:
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
If your using VB.NET your GUID should be: <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
- Save and close .csproj file.
- Open the Solution up (.sln file).
- You are now ready to write tests.
- To run your tests:
- In Solution Explorer double click the .vsmdi file to open the Test Manager window
- Check the test you want to run
- Right mouse click the test and select Run Checked Test.

This problem is quite interesting due to the fact that the .vsmdi file and .testrunconfig exist at the Solution level and not the Project level. In the past this interesting fact was a small hurdle for our automation team because we needed to create a Visual Studio template for a Test Project, but Visual Studio only templates Projects and not Solutions (again the .vsmdi & .testrunconfig need to exist at the .sln level). I'll save the explanation of that workaround for another day!
|
|
| |
 |
|
| |
|
|
| |
|
|
 |
|
 |
|
|
|
| QA Blogs |
|
|
| Profile |
 |
About Brent Strange |
|
E-mail
|
 |
Instant Message |
|
| Blog Archive |
List all Posts
| March, 2010 (2) |
| February, 2010 (4) |
| January, 2010 (4) |
| December, 2009 (2) |
| September, 2009 (1) |
| July, 2009 (1) |
| June, 2009 (1) |
| May, 2009 (2) |
| April, 2009 (2) |
| March, 2009 (5) |
| February, 2009 (4) |
| January, 2009 (1) |
| December, 2008 (2) |
| November, 2008 (2) |
| September, 2008 (7) |
| August, 2008 (1) |
| July, 2008 (3) |
| June, 2008 (1) |
| May, 2008 (2) |
| April, 2008 (9) |
| March, 2008 (14) |
| February, 2008 (8) |
| January, 2008 (14) |
| December, 2007 (7) |
| November, 2007 (5) |
| October, 2007 (13) |
| September, 2007 (11) |
| August, 2007 (4) |
| July, 2007 (1) |
| June, 2007 (4) |
| May, 2007 (10) |
| April, 2007 (7) |
| March, 2007 (6) |
| February, 2007 (12) |
| January, 2007 (18) |
| December, 2006 (6) |
| November, 2006 (5) |
| October, 2006 (22) |
| September, 2006 (12) |
| August, 2006 (17) |
| July, 2006 (11) |
| June, 2006 (20) |
| May, 2006 (17) |
| April, 2006 (23) |
| March, 2006 (28) |
| February, 2006 (15) |
| January, 2006 (21) |
| December, 2005 (14) |
| July, 2005 (2) |
| January, 2005 (1) |
|
| Legal Mumbo-Jumbo |
The opinions expressed herein are not necessarily those of my employer, not necessarily mine, and probably not necessary.
Copyright 2010 Brent Strange
|
|