public void TestPerformArchiveOneDirectory() { var stfArchiver = new StfArchiver(TestContext.TestName); stfArchiver.AddDirectory(@"C:\Temp\Stf\Config"); stfArchiver.PerformArchive(); }
public void TestPerformArchiveZeroAndOneFile() { var stfArchiver = new StfArchiver(TestContext.TestName); stfArchiver.AddFile(@"C:\Temp\Stf\Config\StfConfiguration.xml"); stfArchiver.PerformArchive(); }
public void TestPerformArchiveOneDirectory() { StfArchiver.AddDirectory(@"C:\Temp\Stf\Config"); var oneFileStatusTxt = StfArchiver.Status(); const string ExpectedStatusTxt = "Directories to archive\n\tC:\\Temp\\Stf\\Config\n"; Assert.AreEqual(ExpectedStatusTxt, oneFileStatusTxt); StfArchiver.PerformArchive(); }
public void TestPerformArchiveAndZip() { var stfArchiver = new StfArchiver(TestContext.TestName); const string ZipFilename = @"c:\temp\Stf\StfArchiver.zip"; stfArchiver.AddDirectory(@"C:\Temp\Stf\Config"); stfArchiver.Configuration.ZipFilename = ZipFilename; stfArchiver.PerformArchive(); Assert.IsTrue(File.Exists(ZipFilename)); }
/// <summary> /// The add resultfiles. /// </summary> private void AddResultfiles() { if (!testResultFiles.Any()) { return; } foreach (var resultFile in testResultFiles) { TestContext.AddResultFile(resultFile); StfArchiver.AddFile(resultFile); } }
public void TestPerformArchiveAndZip() { const string ZipFilename = @"c:\temp\Stf\StfArchiver.zip"; File.Delete(ZipFilename); Assert.IsFalse(File.Exists(ZipFilename)); StfArchiver.AddDirectory(@"C:\Temp\Stf\Config"); StfArchiver.Configuration.ZipFilename = ZipFilename; StfArchiver.PerformArchive(); Assert.IsTrue(File.Exists(ZipFilename)); }
public void TestPerformArchiveOneDirectory() { var stfArchiver = new StfArchiver(TestContext.TestName); var dirToArchive = Path.Combine(Directory.GetCurrentDirectory(), @"TestData"); stfArchiver.AddDirectory(dirToArchive); var oneFileStatusTxt = stfArchiver.Status(); var expectedStatusTxt = $"Directories to archive\n\t{dirToArchive}\n"; Assert.AreEqual(expectedStatusTxt, oneFileStatusTxt); stfArchiver.PerformArchive(); }
public void TestPerformArchiveZeroAndOneFile() { var stfArchiver = new StfArchiver(TestContext.TestName); var emptyStatusTxt = stfArchiver.Status(); Assert.AreEqual("Nothing to Archive", emptyStatusTxt); stfArchiver.AddFile(@".\TestData\StfConfiguration.xml"); var oneFileStatusTxt = stfArchiver.Status(); const string ExpectedStatusTxt = "Files to archive\n\t.\\TestData\\StfConfiguration.xml\n"; Assert.AreEqual(ExpectedStatusTxt, oneFileStatusTxt); stfArchiver.PerformArchive(); }
public void TestPerformArchiveZeroAndOneFile() { StfArchiver.Configuration.DoArchiveFoldersAndFiles = true; StfArchiver.Configuration.DoArchiveToZipfile = false; var emptyStatusTxt = StfArchiver.Status(); Assert.AreEqual("Nothing to Archive", emptyStatusTxt); StfArchiver.AddFile(@"C:\Temp\Stf\Config\StfConfiguration.xml"); var oneFileStatusTxt = StfArchiver.Status(); const string ExpectedStatusTxt = "Files to archive\n\tC:\\Temp\\Stf\\Config\\StfConfiguration.xml\n"; Assert.AreEqual(ExpectedStatusTxt, oneFileStatusTxt); StfArchiver.PerformArchive(); }
/// <summary> /// The set up archiver if necessary. /// </summary> /// <param name="testName"> /// The test name. /// </param> private void SetUpArchiver(string testName) { var stfConfiguration = Get <StfConfiguration>(); var archiverConfiguration = new StfArchiverConfiguration(); try { stfConfiguration.LoadUserConfiguration(archiverConfiguration); } catch (Exception exception) { var msg = $"Something went wrong while loading user configuration for archiver: {exception.Message}"; StfLogger.LogError(msg); } archiverConfiguration.ArchiveTopDir = StfTextUtils.ExpandVariables(archiverConfiguration.ArchiveTopDir); archiverConfiguration.ArchiveDestination = StfTextUtils.ExpandVariables(archiverConfiguration.ArchiveDestination); archiverConfiguration.TempDirectory = StfTextUtils.ExpandVariables(archiverConfiguration.TempDirectory); StfArchiver = new StfArchiver(archiverConfiguration, testName); }
public void TestPerformArchiveAndZip() { var stfArchiver = new StfArchiver(TestContext.TestName); const string ZipFilename = @"c:\temp\Stf\StfArchiver.zip"; if (File.Exists(ZipFilename)) { File.Delete(ZipFilename); } Assert.IsFalse(File.Exists(ZipFilename)); stfArchiver.AddDirectory(@".\TestData"); stfArchiver.Configuration.ZipFilename = ZipFilename; stfArchiver.Configuration.DoArchiveFoldersAndFiles = false; stfArchiver.Configuration.DoArchiveToZipfile = true; Assert.IsTrue(stfArchiver.PerformArchive()); Assert.IsTrue(File.Exists(ZipFilename)); }
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); } }