Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2013 - Stop MS Test from deploying into Test Results folder

I work with Coded UI Tests and Visual Studio 2013. Now I have to test if images from a folder are shown correctly inside the application. That’s why I have created a folder containing the images and set build action to none and deployment to always.

Unfortunately all tests are executed in an own test results folder and my images are not deployed correctly. I know I could do this by using the DeploymentItem attribute or a testsettings file but I don't want to do this. I want to avoid the "test results" folder and run the tests from within the output folder of my test project.

I do this with the unit tests for instance. They are written with XUnit.Net which works just fine. I thought it would also work with MS Test but this only seems to work for Unit Tests but not for Coded UI Tests.

So, to sum it up again: How can I get rid of the “Test Results” folder when using Coded UI Tests with Visual Studio 2013 and run my tests simply from within the output directory of the project?

like image 762
HerrLoesch Avatar asked Feb 21 '14 21:02

HerrLoesch


People also ask

How do I stop a test case from running in Visual Studio?

You need to close the Test Explorer Window to prevent automatic running.

How do I run Mstest in Visual Studio?

Test shortcuts Tests can be run from Test Explorer by right-clicking in the code editor on a test and selecting Run test or by using the default Test Explorer shortcuts in Visual Studio.

How do I run a single test case in Visual Studio?

According to this answer (By Jon Skeet no less) it is possible in Visual studio natively too. To debug a single test: Click on a test method name, then press Ctrl+R, Ctrl+T. (Or go to Test / Debug / Tests in Current Context.)


1 Answers

You can do this using a custom entry in the .runsettings file I think.

DeploymentItemAttribute Class

Consider running your unit tests directly in the build output directory, so that testing runs more rapidly. This is especially useful on the build server after you have checked in your tests. To do this, add a .runsettings file to your solution, include False, and select the file in the Test, Test Settings menu. The same effect occurs in any test run in which DeploymentItemAttribute is not used at all.

However, you might prefer not to do this if you want to be able to inspect the data files after a failed run.

You cannot avoid using a deployment folder if you are using a .testsettings file, which is required for web and load tests, coded UI tests, and any test in which you deploy an application to remote machines.

As for DeploymentItemAttribue itself I would steer clear of it unless the following issues have been fixed, Gotchas: MSTest’s [DeploymentItem] attribute. +1 for xUnit in TestDriven.NET.

like image 50
Ade Miller Avatar answered Dec 12 '22 00:12

Ade Miller