当前位置: 动力学知识库 > 问答 > 编程问答 >

visual studio - Different deployment items for each test

问题描述:

I have different tests with different deployment items, like this:

[TestMethod]

[DeploymentItem("item1.xml")]

public void Test1(){...}

[TestMethod]

[DeploymentItem("item2.xml")]

public void Test2(){...}

If I run the tests one by one it works, however if I run them all togheter all the deployment items are copied, so Test2 will run wit item1.xml and item2.xml in the output folder.

What I am trying to do is run each test only with the specified deployment items in the output folder.

Is there any way to clean deployment items after each test?

My workaround is deploying the items to an output subfolder for each test, but I dont like it.

网友答案:

If you define the following in your test class, you may be able to accomplish what you're looking for:

[TestInitialize()]
public void Setup()
{
    //Delete all files from the deployment directory
}

I tend not to use files as part of 'unit' tests, so I'm not positive about this, but it's probably worth looking into if you'd really prefer the files to be isolated in that directory, and not in sub-directories.

分享给朋友:
您可能感兴趣的文章:
随机阅读: