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

前端 未结 7 1759
不思量自难忘°
不思量自难忘° 2020-11-28 18:44

I can\'t seem to grasp how MSTest deployment items are supposed to be configured. I have been able to get them working properly by modifying the project\'s test settings fil

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 19:18

    In Visual Studio 2012 the output directory is the working directory which means that the DeploymentItem attribute isn't needed for the general case (where you don't have specific per-test or per-class deployment items). This means that if you don't need to use the DeploymentItem attribute if there is a set of files that you want all your tests to use or you are not too pernickety about each TestClass/TestMethod having separate deployment dependencies.

    You can simply click Project | Show All Files and include the subfolders and files in Visual Studio with the 'Copy always' or 'Copy if newer' attribute to your project and the files will be copied to your output directory with hierarchy intact.

    The same applies when running vstest.console.exe from the command line. See here for the details.

    Update

    There are cases where the default directory will not be the output directory. Specifically when you choose Run All Tests the default path would be under TestResults\Deploy_... The same applies when using a runsettings file or tests use DeploymentItems

    The output directory will be the default directory when you are not using DeploymentItems and: -

    • You right click the test(s) in Visual Studio and choose to run / debug, or
    • You run from the command line using vstest.console.exe.

提交回复
热议问题