I need to copy some directories/files for MS Unit test, and I have this code.
[TestInitialize()]
[DeploymentItem("\\library", "library")]
public void Initialize()
{
....
}
The problem is that the directory/files are not copied with [TestInitialize()]
, I needed to use as follows:
[TestMethod]
[DeploymentItem("\\library", "library")]
public void AddInt16()
{
...
}
Am I supposed to use DeploymentItem only with [TestMethod]
? If not, what's wrong with my code?
You can use it at a method or class level:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public sealed class DeploymentItemAttribute : Attribute
so, a good workaround given that its not picked up by TestInitialize
is to move the DeploymentItem
to your class.
Either define the deployment item at class level or at the .testrunconfig file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With