MSTest copy file to test run folder

前端 未结 6 1157
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 11:33

I\'ve got a test which requires an XML file to be read in and then parsed. How can I have this file copied into the test run folder each time?

The XML file is set to

6条回答
  •  旧时难觅i
    2020-12-04 12:32

    You can define DeploymentItem in a class that holds a method with AssemblyInitialize attribute. Then you're sure that the files are copied regardless of which test you run.

    Unfortunately DeploymentItem attribute is executed only on classes which contain tests you're running. So if you have 10 test classes which use the same set of files, you have to add the attribute to all of them.

    Also found out that changes in *.testsettings files are not automatically refreshed in Visual Studio. Therefore after adding files / folders into deployment in testsettings, you have to reopen solution file and then run the tests.

提交回复
热议问题