以下代码未在我的NUnit测试中运行。相反,它会中止测试:
[TestFixture]
public class ShimTest
{
[Test]
public void Test_Load_Assemblies()
{
//NUnit runs with no entry assembly, so it would return null
Shim shim = Shim.Replace(() => Assembly.GetEntryAssembly()).With(
Assembly.GetCallingAssembly
);
PoseContext.Isolate(
() =>
{
//This never seems to run
Assembly a = Assembly.GetEntryAssembly();
System.Diagnostics.Debug.WriteLine(a);
},
shim
);
}
}
它失败并显示:
2019.06.18 16:46:04.175错误进程C:\ Users \ MyUser \ AppData \ Local \ JetBrains \ Installations \ ReSharperPlatformVs16_9fb20a7b_001 \ ReSharperTestRunner64.exe:20696退出,代码为-1073741819。
2019.06.18 16:46:04.177警告元素ShimTest.Test_Load_Assemblies在其运行完成后保持运行状态。
2019.06.18 16:46:04.177警告元素ShimTest在运行完成后保持运行状态。