简体   繁体   中英

DeploymentItem(Path, outputDirectory) not working in new Unit-Test project

i'm currently working on a task in a project. We have many Test-Projects in the solution reprository, which are using the DeploymentItem() attribute(all of the Tests are working).

My Problem:

I created a new Directory in the root of the reprository and in the Directory is a new Test-Project. The new tests are not deploying items or something else and using a wrong output path.(All tests not working because no items are deploying)

All old Test-Projects are using "TestResults" Directory. After every build/run of a test a new sub directory ist created named like "Deploy_xxx_Date". My Test-Project is using as output path the default directory bin/Debug. How can i change it that my Project is also using the default TestResults Directory automaticly? And which is the best way to Deploy items?

Hint:

output of old Tests: C:..\\RootOfProject\\SolutionDir\\TestResults\\generatedFolderWithDeploymentItems

output of my Tests: C:..\\RootOfProject\\Tests\\ProjectDir\\bin\\Debug\\NothingDeployed

my Project also should have this output Directory: C:..\\RootOfProject\\SolutionDir\\TestResults\\FolderWithDeploymentItems

Error after a test is running:

Test file 'C:Tests\\TESTPROJECT\\bin\\Debug\\ItemWhichShouldBeDeployed' does not exist.

You should change the properties of the item in the Test project that need be copied as Deployment Item. Right click on the item and set following options Build Action : None and Copy to output Directory : Copy always or Copy if newer (see below), save the project and try again.

在此处输入图片说明

@vendettamit It worked thank you. Now i have another problem: I have different Testprojects in different testdirectories. ...\\rootRepository\\anotherDirectory\\Testing\\Testproject1.csproj ...\\rootRepository\\NewTestDirectoryWhereAllTestsFrom_AnotherDirectory_ShouldBePostponed\\Testproject2Copy_ThisIsAnOtherTestProject.csproj

If i only run the testproject "Testproject2Copy_ThisIsAnOtherTestProject.csproj" everthing is working correctly, but if i run "Testproject2Copy_ThisIsAnOtherTestProject.csproj" and "Testproject1.csproj" together the i get for all tests in Testproject2Copy_ThisIsAnOtherTestProject.csproj the error: Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException: Assert.Fail failed. Test file '......\\TestResults\\Deploy_xxxDate\\Out..\\example.cmd' does not exist.. Aborting test execution.

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