简体   繁体   中英

Changing Output path of the Unit Test project in Visual Studio 2008

I changed the output path of the test project, because the default path doesn't conform to our projects directory structure. After I did that, Visual Studio 2008 fails to run the tests, because it can't find the Unit Test project assembly.

What else do I have to change for the Unit Test Engine to find the assembly?

There are at least three ways to solve this problem

  1. Set up the output path before you run any test in the solution (as suggested by Paulius Maruška ).
  2. Close the solution, delete the directory TestResults (under your solution folder) and then open the solution and run all tests (Test -> Run -> All...)
  3. Add your assembly to the list of files to deploy in the .testconfig file ( suggested by Ty )

Solution number 3 is probably not recommended, since solution 1 or 2 will achieve the same without adding a second reference to the output path.

Please note that solution number 2 will delete any test history you may have.

If you open up your .testrunconfig file and go to the Deployment option, you can add your test assembly to the list of files to deploy. You should then be able to run your tests.

I figured this out, I think.

This is the only solution I have found. Adding the assembly to the files to deploy list (as suggested by Ty) works, but it kind of feels dirty, so I didn't want to do that.

Visual Studio accepts the changed path, only when you change it before running any of the tests. So, the solution to my own question is: You have to create a new test project, change it's build path, add all of the tests from the old test project .

Close your project, then delete your hidden .suo file and the csproj.user file. Then re-open the project. That fixes it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM