// // Main //////////////////////////////////////////////////////////////////////////////// static void Main(string[] args) { SharedBase.Config.Headless = false; List <String> suitesToRun = new List <String>(); suitesToRun.Add("Search-Weather-In-Your-City"); // // Define Suites // List <TestSuite> testSuites = new List <TestSuite>(); // // Search Weather In Your City Test Suite // SearchWeatherInYourCity searchWeatherInYourCity = new SearchWeatherInYourCity(browser); TestSuite testSuite = new TestSuite(); testSuite.Name = "Search-Weather-In-Your-City"; testSuite.AddTest("Search Weather In Your Country", new TestDelegate(searchWeatherInYourCity.SearchWeatherInYourCountry)); testSuites.Add(testSuite); // // Run Suites // Boolean isFirstTestSuite = true; foreach (TestSuite ts in testSuites) { if (suitesToRun.Contains(ts.Name)) { if (isFirstTestSuite) { isFirstTestSuite = false; } else { SharedBase.Log(""); SharedBase.Log(""); SharedBase.Log(""); } RunTestSuite(ts); } else { SharedBase.Log("Skipped Test Suite: '" + ts.Name + "'", 0); } } // // Write Results // StringBuilder sb = new StringBuilder(); sb.Append("<html>"); sb.Append("<head>"); sb.Append("<title>Test Run Results</title>"); sb.Append("</head>"); sb.Append("<body style=\"font-family: Arial; font-size: 14px; padding: 32px;\">"); Int32 successful = 0; Int32 failed = 0; Int32 skipped = 0; foreach (TestSuite executedTestSuite in ExecutedTestSuites) { foreach (NamedTestDelegate test in executedTestSuite.NamedTestDelegates) { if (test.TestResult == TestResult.SUCCESS) { successful += 1; } else if (test.TestResult == TestResult.FAIL) { failed += 1; } else if (test.TestResult == TestResult.SKIPPED) { skipped += 1; } } } sb.Append("<h1>Test Run Report, Successful: " + successful + ", Skipped: " + skipped + ", Failed: " + failed + "</h1>"); foreach (TestSuite executedTestSuite in ExecutedTestSuites) { sb.Append("<h2>" + executedTestSuite.Name + "</h2>"); foreach (NamedTestDelegate test in executedTestSuite.NamedTestDelegates) { String color = COLOR_LIGHT_GREY_ON_WHITE; if (test.TestResult == TestResult.SUCCESS) { color = COLOR_GREEN; } else if (test.TestResult == TestResult.FAIL) { color = COLOR_RED; } else if (test.TestResult == TestResult.SKIPPED) { color = COLOR_ORANGE; } sb.Append("<div style=\"width: 16px; height: 16px; display: inline-block; vertical-align: middle; background-color: " + color + "; border-radius: 50%; margin-right: 8px;\"></div>"); sb.Append("<div style=\"display: inline-block; vertical-align: middle;\">" + test.Name + "</div>"); sb.Append("<br />"); if (test.Exception != null) { sb.Append("<div style=\"padding-left: 24px; color: #888888; padding-top: 8px; padding-bottom: 8px;\">"); sb.Append(SharedBase.FormatException(test.Exception).Replace("\n", "<br />")); sb.Append("</div>"); } if (test.Screenshot != "") { sb.Append("<div style=\"padding-left: 24px; padding-top: 8px; padding-bottom: 8px;\">"); sb.Append("<a href=\"" + test.Screenshot + "\"><img src=\"" + test.Screenshot + "\" width=\"192\" height=\"108\" style=\"border: 0px;\" /></a>"); sb.Append("</div>"); } } } sb.Append("</body>"); sb.Append("</html>"); System.IO.File.AppendAllText(TestBase.ProjectPath + "\\Logs\\Test Run Results " + TestBase.RunId + ".html", sb.ToString()); }