public void TestMethodSummaryLogger() { var logDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @".\Data")); var summaryFilename = Path.Combine(StfTextUtils.GetVariable("Stf_LogDir"), "TestMethodSummaryLogger_SummaryLog.html"); var oneSummaryLogger = new StfSummaryLogger(); StfAssert.IsTrue("StfLogger.CreateSummaryLog", oneSummaryLogger.CreateSummaryLog(summaryFilename, logDir, "DatadrivenLoggerTest_*.html")); StfAssert.FileExists("StfLogger.CreateSummaryLog", summaryFilename); }
public void BaseTestCleanup() { LogBaseClassMessage("StfTestScriptBase BaseTestCleanup"); var testFailed = !StfIgnoreRow && TestContext.CurrentTestOutcome != UnitTestOutcome.Passed && TestContext.CurrentTestOutcome != UnitTestOutcome.Inconclusive; if (testFailed) { StfLogger.LogError("Test failed"); } if (!TestDataDriven()) { StfArchiver.AddFile(StfLogger.FileName); StfArchiver.AddFile(kernelLogFilePath); StfLogger.LogInfo(StfArchiver.Status()); StfLogger.CloseLogFile(); StfArchiver.PerformArchive(); } else { StfIterationNo = DataRowIndex(); StfLogger.CloseLogFile(); if (StfIterationNo == TestContext.DataRow.Table.Rows.Count) { var myStfSummaryLogger = new StfSummaryLogger(); var summaryLogfileLogDirname = Path.GetDirectoryName(StfLogger.FileName); var myLoggerFileName = Path.GetFileName(StfLogger.FileName) ?? string.Empty; var summaryLogfileLogFilename = Regex.Replace(myLoggerFileName, @"_[0-9]+\.html", ".html"); var summaryLogfilename = $@"{summaryLogfileLogDirname}\SummaryLogfile_{summaryLogfileLogFilename}"; var summaryLogfileLogfilePattern = Regex.Replace(myLoggerFileName, @"_[0-9]+\.html", "_*"); myStfSummaryLogger.CreateSummaryLog(summaryLogfilename, summaryLogfileLogDirname, summaryLogfileLogfilePattern); TestContext.AddResultFile(summaryLogfilename); AddResultfiles(); StfArchiver.AddFile(summaryLogfilename); StfArchiver.PerformArchive(); } } if (StfIgnoreRow) { // DoCleanUpAndThrowInconclusive will do the throwing if needed return; } if (!testFailed && StfAssert.CurrentInconclusives > 0 && StfAssert.CurrentFailures <= 0) { var msg = $"Testmethod [{TestContext.TestName}] is inconclusive. Number of inconclusive results: [{StfAssert.CurrentInconclusives}]"; throw new AssertInconclusiveException(msg); } if (!testFailed && StfAssert.CurrentFailures > 0) { var msg = $"Testmethod [{TestContext.TestName}] failed. Number of asserts that failed: [{StfAssert.CurrentFailures}]"; throw new AssertFailedException(msg); } }