How to refer to test files from Xunit tests in Visual Studio?

前端 未结 4 926
抹茶落季
抹茶落季 2021-02-03 21:34

We’re using Xunit for testing. We’re running our tests via the built-in Visual Studio 2013 Test Runner, using the Xunit plugin.

The issue is that some of the tests need

4条回答
  •  礼貌的吻别
    2021-02-03 22:05

    I am running .Net Core 1.0 on Mac. Assembly.GetExecutingAssembly is unavailable. I use the following code instead:

    var location = typeof(YourClassName).GetTypeInfo().Assembly.Location;
    var dirPath = Path.GetDirectoryName(location);
    return Path.Combine(dirPath, relativePath);
    

    relativePath is the path relative to the directory of your DLL.

提交回复
热议问题