/// <summary> /// Executes the provided test batch /// </summary> /// <param name="run">The test batch which will be executed.</param> /// <param name="runContext">The RunContext for this TestCase. Determines whether the test should be debugged or not.</param> /// <param name="frameworkHandle">The FrameworkHandle for this test execution instance.</param> /// <returns></returns> private static bool ExecuteTests(TestRun run, IRunContext runContext, IFrameworkHandle frameworkHandle) { if (run.Runner != null) { if (runContext.IsBeingDebugged) { run.Debug(frameworkHandle); } else { run.Run(); } } else { Logger.Error("No suitable executor found for [{0}].", string.Join(", ", run.Tests)); } return(run.Runner != null); }
partial void StartTestButtonClick(NSObject sender) { StartTestButton.Enabled = false; ShowStatisticsButton.Enabled = false; HideTestResultsData(); TestRun = new TestRun(); TestRun.Run(PathToRectangleAppField.StringValue, TimeoutField.IntValue); CurrentAngelLabel.Hidden = false; CurrentAngelValueLabel.Hidden = false; FpsLabel.Hidden = false; FpsValueLabel.Hidden = false; Device.StartTimer(new TimeSpan(0, 0, 1), () => { CurrentAngelValueLabel.StringValue = Convert .ToInt32(TestRun.ApplicationData.RotationAngelList.GetLastValue()).ToString(); FpsValueLabel.StringValue = Convert .ToInt32(1000000 / TestRun.ApplicationData.FrameRenderTimeList.GetLastValue()).ToString(); if (!TestRun.IsCompleted) { return(true); } HideRuntimeApplicationData(); TestFinishedLabel.Hidden = false; StatusLabel.Hidden = false; StatusValueLabel.StringValue = TestRun.TestResult.ToString(); StatusValueLabel.Hidden = false; if (TestRun.TestResult == TestResultsEnum.Failed) { DetailsLabel.Hidden = false; DetailsTextView.Value = TestRun.FailData; DetailsTextView.Hidden = false; } StartTestButton.Enabled = true; ShowStatisticsButton.Enabled = true; return(false); }); }
public override bool Execute() { // There's nothing to do if we have no source files if (String.IsNullOrEmpty(XapFile)) { return(true); } if (String.IsNullOrEmpty(ApplicationProductId) && !String.IsNullOrEmpty(ApplicationManifest)) { ApplicationProductId = GetApplicationProductId(); if (!String.IsNullOrEmpty(ApplicationProductId)) { Log.LogMessage("ProductId extracted from manifest: {0}", ApplicationProductId); } } if (String.IsNullOrEmpty(ApplicationProductId)) { Log.LogError("ApplicationProductId was not supplied and could not be found"); return(false); } // Process the files bool succeeded = true; try { string testPath = XapFile; FileInfo testApplication = new FileInfo(testPath); // Make sure they didn't pass a directory as an item if (Directory.Exists(testPath)) { Log.LogError("Cannot move item {0} because it is a directory!", testPath); return(false); } // Make sure the source exists if (!testApplication.Exists) { Log.LogError("Cannot process file {0} that does not exist!", testPath); return(false); } string testName = GetTestName(testApplication.Directory); if (!string.IsNullOrEmpty(TagExpression)) { testName += " (" + TagExpression + ")"; } string name = TestResultsFile; if (string.IsNullOrEmpty(name)) { int k = 1; name = "TestResults.trx"; while (File.Exists(Path.Combine(testApplication.DirectoryName, name))) { name = string.Format(CultureInfo.InvariantCulture, "TestResults{0}.trx", k++); } } FileInfo log = new FileInfo(Path.Combine(testApplication.DirectoryName, name)); Log.LogMessage("Begin unit testing"); TestRunOptions tro = new TestRunOptions { XapFile = testApplication.FullName, ApplicationProductId = new Guid(ApplicationProductId), UpdateApplication = UpdateApplication, DeviceInfo = CreateDeviceInfo(), TagExpression = TagExpression, Log = log.FullName, LocalPath = Path.GetDirectoryName(log.FullName) }; tro.Page = testApplication.Name; TestRun tr = new TestRun( new TestServiceOptions(), tro); tr.Run(); // Interpret results string pass = null; string total = null; if (log.Exists) { DisplayTestResults(log, ref total, ref pass); if (DeleteLogFiles) { log.Delete(); } } else { Log.LogError( "The log file {0} was never written by the test service for the {1} test.", log.FullName, testName); } if (tr.Total == 0) { Log.LogWarning( "There were 0 reported scenarios executed. Check that the tag expression is appropriate."); } else if (tr.Failures == 0) { Log.LogMessage( MessageImportance.High, "Unit tests ({0}): {1}{2}", testName, pass != null ? " " + pass + " passing tests" : "", total != null ? " " + total + " total tests" : ""); } else { succeeded = false; LogFailureMessage( "Unit test failures in test " + testName + ", " + tr.Failures.ToString(CultureInfo.CurrentUICulture) + " failed scenarios out of " + tr.Total.ToString(CultureInfo.CurrentUICulture) + " total scenarios executed."); } } catch (Exception ex) { Log.LogErrorFromException(ex); succeeded = false; } return(succeeded); }
public override bool Execute() { // There's nothing to do if we have no source files if (TestPages == null || TestPages.Length == 0) { return(true); } // Process the files bool succeeded = true; try { for (int i = 0; i < TestPages.Length; i++) { string testPath = TestPages[i].ItemSpec; FileInfo testApplication = new FileInfo(testPath); // Make sure they didn't pass a directory as an item if (Directory.Exists(testPath)) { Log.LogError("Cannot move item {0} because it is a directory!", testPath); succeeded = false; continue; } // Make sure the source exists if (!testApplication.Exists) { Log.LogError("Cannot process file {0} that does not exist!", testPath); succeeded = false; continue; } string testName = GetTestName(testApplication.Directory); if (!string.IsNullOrEmpty(TagExpression)) { testName += " (" + TagExpression + ")"; } string name = TestResultsFile; if (string.IsNullOrEmpty(name)) { int k = 1; name = "TestResults.trx"; while (File.Exists(Path.Combine(testApplication.DirectoryName, name))) { name = string.Format(CultureInfo.InvariantCulture, "TestResults{0}.trx", k++); } } FileInfo log = new FileInfo(Path.Combine(testApplication.DirectoryName, name)); WebBrowserBrand wbb = WebBrowserFactory.ParseBrand(Browser); TestRunOptions tro = new TestRunOptions { // StartupUri = testApplication.Name, Browser = wbb, LocalPath = testApplication.DirectoryName, TagExpression = TagExpression, }; tro.Page = testApplication.Name; tro.Log = log.FullName; if (wbb == WebBrowserBrand.Custom) { tro.SetCustomBrowser(Browser); } TestRun tr = new TestRun( new TestServiceOptions(), tro); tr.Run(); // Interpret results string pass = null; string total = null; if (log.Exists) { DisplayTestResults(log, ref total, ref pass); if (DeleteLogFiles) { log.Delete(); } } else { Log.LogWarning( "The log file {0} was never written by the test service for the {1} test.", log.FullName, testName); } if (tr.Total == 0) { Log.LogWarning("There were 0 reported scenarios executed. Check that the tag expression is appropriate."); } else if (tr.Failures == 0) { Log.LogMessage( MessageImportance.High, "Unit tests ({0}): {1}{2}", testName, pass != null ? " " + pass + " passing tests" : "", total != null ? " " + total + " total tests" : ""); } else { succeeded = false; LogFailureMessage( "Unit test failures in test " + testName + ", " + tr.Failures.ToString(CultureInfo.CurrentUICulture) + " failed scenarios out of " + tr.Total.ToString(CultureInfo.CurrentUICulture) + " total scenarios executed."); } } } catch (Exception ex) { Log.LogErrorFromException(ex); succeeded = false; } return(succeeded); }