You can do this by using a .runsettings file, and setting <DeploymentEnabled>false</DeploymentEnabled>
. See the "Remarks" section here. However, you can't do this if you are using a .testsettings file, and if you want to be able to inspect any files that your tests read or write after a failed run, you might not be able to, because they could be tainted by further tests etc.
Another option is to use deployment items, which can be done through the DeploymentItemAttribute
or through your .testsettings file. The attribute mechanism is preferred, and basically, on test methods that you need to deploy files for you do the following:
[DeploymentItem(@"source", @"target")]
public void Test1() {}
Where source is either a path relative to the build output folder, or an absolute path, and target is either a path relative to where the tests run from, or an absolute path. You can leave the target parameter out, in this case it will assume a target of ".", ie the folder where the tests are running from. The docs for this are here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…