How to get MSTest to find my test data files?

后端 未结 3 1631
别跟我提以往
别跟我提以往 2021-02-05 03:00

I have a few tests that need to be fed with external data from excel files. The files are included in the test project, and in Visual Studio, I have edited the test settings fil

3条回答
  •  既然无缘
    2021-02-05 03:56

    I get round this by adding my data files (in my case usually XML) as embedded resources and I extract them from the test assembly.

    [TestInitialize]
    public void InitializeTests()
    {
        var asm = Assembly.GetExecutingAssembly();
        this.doc = new XmlDocument();
        this.doc.Load(asm.GetManifestResourceStream("TestAssembly.File.xml"));
    }
    

提交回复
热议问题