public virtual void RunTest(LoggingLevel preferredLoggingLevel, string rootDirectory) { if (CoarseGrind.KILL_SWITCH) { // Decline to run } else { bool setupResult = true; parentArtifactsDirectory = rootDirectory; Guid thisOutputIdentifier = Log.AddOutput(new TextOutputManager( ArtifactsDirectory + Path.DirectorySeparatorChar + LogFileName), preferredLoggingLevel, LoggingMode.Minimum); LogTestHeader(); SetupEnforcement before = null; try { IndicateSetup(); before = new SetupEnforcement(this); try { setupResult = Setup(); } finally { WasSetup = true; } } catch (Exception thisFailure) { setupResult = false; AddResult(GetResultForPreclusionInSetup(thisFailure)); } finally { if (!new SetupEnforcement(this).matches(before)) { setupResult = false; AddResult(new TestResult(TestStatus.Inconclusive, "PROGRAMMING ERROR: It is illegal to change the identifier, name, or priority in Setup. This must happen in the constructor.")); } IndicateSectionEnd(); } if (setupResult && (CoarseGrind.KILL_SWITCH == false)) { try { IndicateBody(); Console.Error.Write("Running " + this.IdentifiedName); executionThread = new Thread(PerformTest); executionThread.Start(); executionThread.Join(); } catch (Exception thisFailure) { AddResult(GetResultForFailure(thisFailure)); } finally { WasRun = true; executionThread = null; IndicateSectionEnd(); } } else { AddResult(new TestResult(TestStatus.Inconclusive, "Declining to perform test case " + IdentifiedName + " because setup method failed.")); } try { IndicateCleanup(); Console.Error.WriteLine(" - " + OverallStatus); Cleanup(); WasCleanedUp = true; } catch (Exception thisFailure) { ReportFailureInCleanup(thisFailure); } finally { IndicateSectionEnd(); } TestStatus overall = OverallStatus; Log.Message("<h1>Overall Status: " + overall.ToString() + "</h1>", overall.ToLoggingLevel(), overall.ToHtmlLogIcon()); Log.ClearSpecificOutput(thisOutputIdentifier); } }
public static void Log(this TestStatus it, string message, LoggingLevel requestedLevel) { Test.Log.Message(message, requestedLevel, it.ToHtmlLogIcon()); }