public void TestNoLog() { TestSet testSet; testSet = buildTestSet("/TestNoLog.xml"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); Reporter reporter = InformationObject.Reporter; string tempLogName = $"{this.logName}.tmp"; File.Copy(this.logName, tempLogName); string logFile; using (StreamReader reader = new StreamReader(tempLogName)) { logFile = reader.ReadToEnd(); } File.Delete(tempLogName); Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful); Assert.IsTrue(reporter.TestCaseStatuses[0].RunSuccessful); Assert.IsTrue(reporter.TestCaseToTestSteps[reporter.TestCaseStatuses[0]][0].RunSuccessful); Assert.IsFalse(logFile.Contains("Name:No logging"), "Log file should not have teststep in it"); }
public void TestAllConcreteTestSteps() { TestSet testSet; testSet = buildTestSet("/TestAllConcreteSteps.xml"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); Reporter reporter = InformationObject.Reporter; Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful); Assert.IsTrue(reporter.TestCaseStatuses[0].RunSuccessful); }
public void TestOneUser() { TestSet testSet; Reporter reporter; testSet = buildTestSet("/Test One User.xlsx"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); reporter = InformationObject.Reporter; Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful, "Expeted to pass"); }
public void TestFailTestStep() { TestSet testSet; testSet = buildTestSet("/TestFailTestStep.xml"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); Reporter reporter = InformationObject.Reporter; Assert.IsFalse(reporter.TestSetStatuses[0].RunSuccessful); Assert.IsFalse(reporter.TestCaseStatuses[0].RunSuccessful); Assert.IsFalse(reporter.TestCaseToTestSteps[reporter.TestCaseStatuses[0]][0].RunSuccessful); }
public void TestNestedIf() { TestSet testSet; Reporter reporter; testSet = buildTestSet("/TestCaseNestedIf.xml"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); reporter = InformationObject.Reporter; Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful, "Expected to pass"); Assert.AreEqual(1, reporter.TestCaseStatuses.Count, "Expected to have 1 test case"); Assert.AreEqual(2, reporter.TestCaseToTestSteps.Sum(x => x.Value.Count), "Expected to have 2 test steps"); }
public void TestAODA() { TestSet testSet; Reporter reporter; testSet = buildTestSet("/TestAODA.xml", $"{webSiteLocation}/Google.html"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); FrameworkDriver.RunAODA(); reporter = InformationObject.Reporter; Assert.IsTrue(Directory.Exists(saveFileLocation)); Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful); }
/// <inheritdoc/> public override void Execute() { base.Execute(); GetEmail ge = new GetEmail(); AutomationTestSetDriver.RunTestStep(ge); ge.Execute(); this.TestStepStatus = ge.TestStepStatus; if (this.TestStepStatus.RunSuccessful) { VerifyEmail ve = new VerifyEmail(); AutomationTestSetDriver.RunTestStep(ve); this.TestStepStatus.RunSuccessful = ve.TestStepStatus.RunSuccessful; this.TestStepStatus.Actual += "\n" + ve.TestStepStatus.Actual; } }
public void TestNoUrl() { TestSet testSet; Reporter reporter; testSet = buildTestSet("/TestNoURL.xlsx"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); reporter = InformationObject.Reporter; Assert.IsFalse(reporter.TestSetStatuses[0].RunSuccessful, "Expeted to fail"); Assert.AreEqual(1, reporter.TestCaseStatuses.Count, "Expected to have 1 test case"); Assert.AreEqual(1, reporter.TestCaseToTestSteps.Sum(x => x.Value.Count), "Expected to have 1 test steps"); }
public void TestChooseUser() { TestSet testSet; Reporter reporter; testSet = buildTestSet("/Test Multiple Users.xlsx;User 2"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); reporter = InformationObject.Reporter; Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful, "Expeted to pass"); Assert.AreEqual(1, reporter.TestCaseStatuses.Count, "Expected to have 1 test case"); Assert.AreEqual(6, reporter.TestCaseToTestSteps.Sum(x => x.Value.Count), "Expected to have 6 test steps"); }
public void TestMissingAction() { TestSet testSet; Reporter reporter; testSet = buildTestSet("/Test Missing Test Action.xlsx"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); reporter = InformationObject.Reporter; Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful, "Expeted to Pass"); Assert.AreEqual(1, reporter.TestCaseStatuses.Count, "Expected to have 1 test case"); Assert.AreEqual(3, reporter.TestCaseToTestSteps.Sum(x => x.Value.Count), "Expected to have 3 test steps"); }
public void TestCannotFindTestStep() { TestSet testSet; try { testSet = buildTestSet("/TestCaseMissingTestStep.xml"); AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); } catch (Exception) { Assert.Pass(); } Assert.Fail(); }
/// <inheritdoc/> public override void Execute() { base.Execute(); string testCaseName = this.Arguments["value"]; ITestCase testCase = InformationObject.TestCaseData.SetUpTestCase(testCaseName); Logger.Info("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"); AutomationTestSetDriver.RunTestCase(testCase); Logger.Info("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); this.TestStepStatus.Actual = testCase.TestCaseStatus.Actual; this.TestStepStatus.RunSuccessful = testCase.TestCaseStatus.RunSuccessful; this.TestStepStatus.Description = testCase.TestCaseStatus.Description; this.TestStepStatus.Expected = testCase.TestCaseStatus.Expected; this.TestStepStatus.ErrorStack = testCase.TestCaseStatus.ErrorStack; }
public void TestWait() { TestSet testSet; testSet = buildTestSet("/TestWait.xml"); var start = DateTime.Now; AutomationTestSetDriver.RunTestSet(testSet); InformationObject.Reporter.Report(); var end = DateTime.Now; Reporter reporter = InformationObject.Reporter; Assert.IsTrue(reporter.TestSetStatuses[0].RunSuccessful); Assert.IsTrue(reporter.TestCaseStatuses[0].RunSuccessful); Assert.AreEqual(5, (end.Second - start.Second), "It should of waited 5 seconds"); }
public void TestCannotFindTestCase() { TestSet testSet; Reporter reporter; testSet = buildTestSet("/TestSetMissingTestCase.xml"); try { AutomationTestSetDriver.RunTestSet(testSet); } catch (Exception) { } InformationObject.Reporter.Report(); reporter = InformationObject.Reporter; Assert.IsFalse(reporter.TestSetStatuses[0].RunSuccessful, "Expected to fail"); Assert.AreEqual(0, reporter.TestCaseStatuses.Count, "Expected to have 0 test case"); Assert.AreEqual(0, reporter.TestCaseToTestSteps.Sum(x => x.Value.Count), "Expected to have 0 test steps"); }
/// <summary> /// The Main functionality. /// </summary> /// <param name="args">Arguments to be passed in.</param> /// <returns> 0 if no errors were met. </returns> public static int Main(string[] args) { bool errorParsing; int resultCode = 0; errorParsing = ParseCommandLine(args); if (!errorParsing) { if (update.Equals("true")) { Logger.Info("Checking for updates..."); if (CheckForUpdates(Assembly.GetExecutingAssembly().Location)) { string newArgs = string.Join(" ", args.Select(x => string.Format("\"{0}\"", x)).ToList()); using (Process p = new Process()) { ProcessStartInfo startInfo = new ProcessStartInfo { UseShellExecute = false, RedirectStandardOutput = false, RedirectStandardError = false, FileName = "AutoUpdater.exe", Arguments = newArgs, }; p.StartInfo = startInfo; p.Start(); } Thread.Sleep(5000); // Closes the current process Environment.Exit(0); } else { Logger.Info("Program is up to date"); } } errorParsing = ParseTestSetParameters(); SetDefaultParameters(); } Logger.Info($"Running AutomationFramework Version: {FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion}"); if (!errorParsing) { // Set up all the parts. InformationObject.SetUp(); TestSetBuilder setBuilder = new TestSetBuilder(); TestSet testSet = setBuilder.Build(); TestAutomationBuilder automationBuilder = new TestAutomationBuilder(); automationBuilder.Build(); // Run main program. DateTime start = DateTime.UtcNow; AutomationTestSetDriver.RunTestSet(testSet); RunAODA(); DateTime end = DateTime.UtcNow; InformationObject.Reporter.Report(); InformationObject.CSVLogger.AddResults($"Total, {Math.Abs((start - end).TotalSeconds)}"); InformationObject.CSVLogger.WriteOutResults(); string resultString = testSet.TestSetStatus.RunSuccessful ? "successful" : "not successful"; Logger.Info($"Automation Testing Program has finished. It was {resultString}"); } else { resultCode = 1; } Environment.Exit(resultCode); return(resultCode); }