1

I'm migrating MSTest cases to XUnit and couldn't find a way to convert DeploymentItem attribute of MSUnit to equivalent in XUnit. Please let me know how to migrate it.

[DeploymentItem("Test Data", "Certificates")]

Thanks in advance.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84

1 Answers1

3

XUnit creators suggest using embedded resources as there is no equivalent

twitter post

You can find some details how to read embedded resources in other questions. Here is one of them:

var assembly = Assembly.GetExecutingAssembly();
var resourceName = "MyCompany.MyProduct.MyFile.txt";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
    string result = reader.ReadToEnd();
}
Yehor Androsov
  • 4,885
  • 2
  • 23
  • 40