What does the DeploymentItem attribute mean?

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.

/// <summary>
///A test for Add
///</summary>
[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.

+3
source share
4

, . , . .

+7

, , , TestRun.

, "consoleTryIt.exe" (, , ) . , FileNotFound.

+1

, "TestResults\Out" / . , bin .
( , ...) , , .

.

+1
  • , , , , MSTest TestResults\Out.

  • " " , bin, MSTest.

  • Verify that the Enable Deployment check box is selected in testrunconfig.

0
source

Source: https://habr.com/ru/post/1770082/


All Articles