在我的Logger类的FinishTestLog()方法中,我能够访问TestContext (使用在别处提供并存储在私有字段中的引用),并获得写入日志的CurrentTestOutcome:if (_testContext != null) message = String.Format("Ended execution of test case with outcome: {0}",
_testContext.CurrentTestOutcom
您可以从TestContext.TestName属性获得此信息。{ public class UnitTest1 public TestContextTestContext { get; setvoid SetupTests(TestContexttestContext) _testContext = testContext;
}=
我正在使用的代码 public class ValidatePDF public NUnit.Framework.TestContextTestContext { get; set; } public void Init() string t = TestContext.TestDirectory;}
TestContext始终为空。Studio2017和NUni
public void ConfigureServices(IServiceCollection services) services.AddDbContextPool<TestContextservices.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
} } 这是我的DBContext public class TestContext