How can I load this file into an NUnit Test?

后端 未结 4 1661
温柔的废话
温柔的废话 2020-12-23 19:19

I have the following IntegrationTest project structure ...

\"enter

If i wish t

4条回答
  •  青春惊慌失措
    2020-12-23 20:08

    If you do not want the files as ManifestResources, but just as file on the system. See Trouble with NUnit when determining the assembly's directory for more info and this answer in particular

    Also interesting is the info from NUnit https://bugs.launchpad.net/nunit-vs-adapter/+bug/1084284/comments/3

    But here is the quick info:

    Path.Combine(TestContext.CurrentContext.TestDirectory, @"Files\test.pdf")
    

    Where Files\test.PDF is just a file in your test project, with build action content and copy to output directory copy if newer

    All credits go out to the people in the other post, but took me a while to find that answer, and that is the reason why i am adding the answer to this post.

提交回复
热议问题