public TestHostContext(object testClass, [CallerMemberName] string testName = "") { ArgUtil.NotNull(testClass, nameof(testClass)); ArgUtil.NotNullOrEmpty(testName, nameof(testName)); _loadContext = AssemblyLoadContext.GetLoadContext(typeof(TestHostContext).GetTypeInfo().Assembly); _loadContext.Unloading += LoadContext_Unloading; _testName = testName; // Trim the test assembly's root namespace from the test class's full name. _suiteName = testClass.GetType().FullName.Substring( startIndex: typeof(Tests.TestHostContext).FullName.LastIndexOf(nameof(TestHostContext))); _suiteName = _suiteName.Replace(".", "_"); // Setup the trace manager. TraceFileName = Path.Combine( Path.Combine(TestUtil.GetSrcPath(), "Test", "TestLogs"), $"trace_{_suiteName}_{_testName}.log"); if (File.Exists(TraceFileName)) { File.Delete(TraceFileName); } var traceListener = new HostTraceListener(TraceFileName); traceListener.DisableConsoleReporting = true; _secretMasker = new SecretMasker(); _secretMasker.AddValueEncoder(ValueEncoders.JsonStringEscape); _secretMasker.AddValueEncoder(ValueEncoders.UriDataEscape); _secretMasker.AddValueEncoder(ValueEncoders.BackslashEscape); _traceManager = new TraceManager(traceListener, _secretMasker); _trace = GetTrace(nameof(TestHostContext)); // inject a terminal in silent mode so all console output // goes to the test trace file _term = new Terminal(); _term.Silent = true; SetSingleton <ITerminal>(_term); EnqueueInstance <ITerminal>(_term); if (!TestUtil.IsWindows()) { string eulaFile = Path.Combine(GetDirectory(WellKnownDirectory.Externals), Constants.Path.TeeDirectory, "license.html"); Directory.CreateDirectory(GetDirectory(WellKnownDirectory.Externals)); Directory.CreateDirectory(Path.Combine(GetDirectory(WellKnownDirectory.Externals), Constants.Path.TeeDirectory)); File.WriteAllText(eulaFile, "testeulafile"); } }