Sergey Shishkin

on agile software development

VSTS Unit Testing: DeploymentItemAttribute

What do you expect to be deployed to the test run folder alongside with the required assemblies when you have such a test class?

[TestClass]
public class MyTest
{
	public const string test1 = "test1.txt";
	[TestMethod()]
	[DeploymentItem("test2.txt")]
	[DeploymentItem(test1)]
	public void Test(){}
}

Suppose you have both “test1.txt” and “test2.txt” files sitting together in the test project’s folder. The answer is: only “test2.txt” will be deployed. Regardless of the fact that constant and literal arguments are identical after compilation, VSTS will only analyze your source code and will do it wrong way!

Remember also, that DeploymentItemAttribute is valid only for methods, not classes. So, if you have 20 test methods and 10 deployment items to copy you have to put 200 DeploymentItemAttributes with literal arguments!

It’s brilliant! I just have nothing more to add!

About these ads

Written by Sergey Shishkin

15.01.2007 at 18:35

Posted in Uncategorized

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: