Say we have a short program:
namespace ConsoleTryIt
{
static class Program
{
static void Main(string[] args)
{
var sum = Add(1, 2);
}
private static int Add(int p, int p2)
{
return p + p2;
}
}
}
When creating the unit test class for this class, Visual Studio will create a test method with an attribute DeploymentItem. I read MSDN about this attribute, but still do not understand what this means.
[TestMethod()]
[DeploymentItem("ConsoleTryIt.exe")]
public void AddTest()
{
var expected = 122;
var actual = Program_Accessor.Add(1, 121);
Assert.AreEqual(expected, actual);
}
If you have an idea, please share!
Edit
Thank you all for your answers. So, the idea is to copy the element specified in the argument to the evironment test folder. My next question is: why does this method need this attribute and others not?
I suppose this is due to private members of the tested class, but nothing is clear to me.
Keep discussing.
source
share