简体   繁体   中英

MS Test, Multiple Test Projects in Solution, and DeploymentItemAttribute

I have two unit test projects in my VS 2010 solution. Each project has a Data directory with input data needed for the unit tests.

I annotated the test classes that need the data with

[DeploymentItem("Data")]

When I run tests individually, the run fine. However, when I run (or debug) all tests in the solution, I find that only one of the two Data directories is copied to TestResults\\MyTestDir-YYYY-MM-DD HH_mm_SS\\Out , causing unit tests that rely on the other data directory to fail.

Interestingly if I then use the Test Results window to re-run checked (as in failed) tests, the tests still fail (they do not recognize that the correct Data directory's files are missing). If I then navigate directly to a failed test and select Run Tests in Current Context, the test run gets the correct Data directory and the test succeeds.

My question : How can I cause DeploymentItem s from two separate test projects all to be copied to the Out directory where the tests are executed?

For reference, I have reviewed these questions without noting a solution

Problems with DeploymentItem attribute

Do MSTest deployment items only work when present in the project test settings file?

I found that giving each "Data" directory a unique name (eg "TestProjectAData") resolved the issue. There seems to be some sort of bug when multiple directories in different paths all have the same relative path to different test projects (ie if every test project has a subdirectory called "Data").

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