private static GallioTestResult CreateTestResult(TestStepRun run, Guid runId, ITestElement test, bool includeTestStepRunXml) { var result = new GallioTestResult(runId, test); result.TestName = run.Step.FullName; result.Outcome = GetOutcome(run.Result.Outcome); foreach (StructuredStream stream in run.TestLog.Streams) { string contents = stream.ToString(); if (stream.Name == MarkupStreamNames.DebugTrace) result.DebugTrace += contents; else if (stream.Name == MarkupStreamNames.ConsoleOutput) result.StdOut += contents; else if (stream.Name == MarkupStreamNames.ConsoleError) result.StdErr += contents; else if (stream.Name == MarkupStreamNames.Failures || stream.Name == MarkupStreamNames.Warnings) result.ErrorMessage += contents; else result.DebugTrace += contents; } result.SetTimings(run.StartTime, run.EndTime, run.Result.Duration); if (includeTestStepRunXml) result.TestStepRunXml = TestStepRunToXml(run); foreach (TestStepRun childRun in run.Children) result.AddInnerResult(CreateTestResult(childRun, runId, test, false)); return result; }
/// <summary> /// Invokes the editor for the specified Gallio test. /// </summary> /// <param name="uiBlob">Identifies the Project/Item blob to be displayed.</param> /// <param name="test">The test that the editor is being invoked for.</param> public void InvokeEditor(UIBlob uiBlob, ITestElement test) { if (!TipShellExtension.IsInitialized) return; GallioTestElement gallioTest = test as GallioTestElement; if (gallioTest != null) { if (gallioTest.Path == null) { ErrorDialog.Show(NativeWindow.FromHandle((IntPtr) dte.MainWindow.HWnd), Properties.Resources.UnknownTestCodeLocationCaption, Properties.Resources.UnknownTestCodeLocation, ""); } else { Window window = dte.OpenFile(EnvDTE.Constants.vsViewKindCode, gallioTest.Path); TextSelection selection = window.Selection as TextSelection; if (gallioTest.Line != 0) { if (selection != null) selection.MoveToLineAndOffset(gallioTest.Line, Math.Max(1, gallioTest.Column), false); } window.Activate(); } } }
public void Run(ITestElement testElement, ITestContext testContext) { if (! running && runContext != null) { running = true; RunAllTests(runContext); } }
/// <summary> /// IBaseAdapter method: called to execute a test. /// </summary> /// <param name="testElement">The test object to run</param> /// <param name="testContext">The Test conext for this test invocation</param> void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) { Trace.TraceInformation("Called DynamicHostAdapter.Run"); ITestAdapter realAdapter = GetTestAdapter(testElement); realAdapter.Run(testElement, testContext); }
public TestProperties(ITestElement testElement, TestRunConfiguration runConfig) { _testElement = testElement; #if !VS11 if (runConfig != null) { _testSettings = runConfig.TestSettingsProperties; } #endif }
void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) { UIThreadInvoker.Initialize(); UIThreadInvoker.Invoke((ThreadInvoker)delegate() { ITestAdapter realAdapter = GetTestAdapter(testElement); realAdapter.Run(testElement, testContext); Trace.TraceInformation("Completed UI thread call to Run"); }); Trace.TraceInformation("Completed incoming call to Run"); }
/// <inheritdoc/> public void Run(ITestElement testElement, ITestContext testContext) { try { var test = testElement as MSVST4U_UnitTestElement; if (test == null) throw new NotImplementedException("XUnitTestAdapter does not currently know how to run tests of type: " + (test == null ? "(null)" : test.GetType().FullName)); var executor = _executors.GetOrAdd(testElement.Storage, s => new ExecutorWrapper(s, configFilename: null, shadowCopy: true)); var result = XUnitTestRunner.ExecuteTest(executor, _runId, test); testContext.ResultSink.AddResult(result); } catch (Exception ex) { Trace.TraceError("Error at UnitTestAdapter.Run: " + ex.Message); throw; } }
/// <summary> /// Get real TA. /// </summary> private ITestAdapter GetTestAdapter(ITestElement test) { Debug.Assert(test != null, "Internal error: test is null!"); Debug.Assert(!string.IsNullOrEmpty(test.Adapter), "Internal error: test.Adapter is null or empty!"); ITestAdapter realTestAdapter = null; bool containsAdapter = m_adapters.TryGetValue(test.Adapter, out realTestAdapter); if (!containsAdapter) { realTestAdapter = (ITestAdapter)Activator.CreateInstance(Type.GetType(test.Adapter), new Object[] { }); // Initialize was delayed to be run from the Run method. realTestAdapter.Initialize(m_runContext); m_adapters.Add(test.Adapter, realTestAdapter); } return realTestAdapter; }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { String xPath = null; if (Url != null) { xPath = $".//a[@href='{Url.Trim()}']"; } else if (Text != null) { xPath = $".//a[normalize-space()={Text.XPathText()}]"; } else if (TestId != null) { xPath = $".//a[@test-id='{TestId}']"; } var elem = control.GetElementByXPath(xPath); elem.Click(); browser.WaitForComplete(); }
/// <summary> /// Gets or creates test element. /// </summary> /// <param name="executionId"></param> /// <param name="parentExecutionId"></param> /// <param name="testType"></param> /// <param name="parentTestElement"></param> /// <param name="rockSteadyTestCase"></param> /// <returns>Trx test element</returns> private ITestElement GetOrCreateTestElement(Guid executionId, Guid parentExecutionId, TestType testType, ITestElement parentTestElement, ObjectModel.TestResult rockSteadyTestResult) { ITestElement testElement = parentTestElement; // For scenarios like data driven tests, test element is same as parent test element. if (parentTestElement != null && !parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) { return(testElement); } TestCase testCase = rockSteadyTestResult.TestCase; Guid testId = this.converter.GetTestId(testCase); // Scenario for inner test case when parent test element is not present. var testName = testCase.DisplayName; var adapter = testCase.ExecutorUri.ToString(); if (adapter.Contains(TrxLoggerConstants.MstestAdapterString) && parentTestElement == null && !string.IsNullOrEmpty(rockSteadyTestResult.DisplayName)) { // Note: For old mstest adapters hierarchical support was not present. Thus inner result of data driven was identified using test result display name. // Non null test result display name means its a inner result of data driven/ordered test. // Changing GUID to keep supporting old mstest adapters. testId = Guid.NewGuid(); testName = rockSteadyTestResult.DisplayName; } // Get test element testElement = GetTestElement(testId); // Create test element if (testElement == null) { testElement = this.converter.ToTestElement(testId, executionId, parentExecutionId, testName, testType, testCase); testElements.TryAdd(testId, testElement); } return(testElement); }
private ScreenRecorder StartSceenRecorder(ITestElement testElement, IRunContext runContext) { string screenCapture; if (!TryGetProperty(testElement, _runContext, VSTestProperties.ScreenCapture.Key, out screenCapture) || string.IsNullOrEmpty(screenCapture)) { return(null); } try { if (!Path.IsPathRooted(screenCapture)) { screenCapture = Path.Combine( _runContext.RunConfig.TestRun.RunConfiguration.RunDeploymentOutDirectory, screenCapture ); } } catch (ArgumentException) { return(null); } screenCapture = screenCapture.Replace("$id$", testElement.HumanReadableId); screenCapture = screenCapture.Replace("$date$", DateTime.Today.ToShortDateString()); var screenRecorder = new ScreenRecorder(screenCapture); string intervalString; int interval; if (TryGetProperty(testElement, runContext, VSTestProperties.ScreenCapture.IntervalKey, out intervalString) && int.TryParse(intervalString, out interval)) { screenRecorder.Interval = TimeSpan.FromMilliseconds(interval); } else { screenRecorder.Interval = TimeSpan.FromSeconds(1); } return(screenRecorder); }
private String GetTestClassName(ITestElement element) { List <String> names = new List <string>(element.HumanReadableId.Split(new char[] { '.' })); String className = String.Empty; if (names.Count > 0 && names[names.Count - 1].Equals(element.Name)) { names.RemoveAt(names.Count - 1); } foreach (String name in names) { if (className != String.Empty && !className.EndsWith(".")) { className += "."; } className += name; } return(className); }
private void SendMessage(IRunContext runContext, string message, ITestElement currentTest = null) { if (runContext == null) { return; } var runId = runContext.RunConfig.TestRun.Id; TestMessage msg; if (currentTest == null) { msg = new TestRunTextResultMessage(runId, message); } else { msg = new TextTestResultMessage(runId, currentTest, message); } runContext.ResultSink.AddResult(msg); }
private bool TryGetProperty( ITestElement testElement, IRunContext runContext, string propertyName, out string value ) { value = null; if (testElement.Properties.ContainsKey(propertyName)) { value = testElement.Properties[propertyName] as string; return(value != null); } #if !DEV11 var runProps = runContext.RunConfig.TestRun.RunConfiguration.TestSettingsProperties; return(runProps.TryGetValue(propertyName, out value)); #else return(false); #endif }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { String xPath = null; if (Text != null) { xPath = $".//button[contains(@class,'btn')][normalize-space()={Text.XPathText()}]"; } else if (Icon != null) { xPath = $".//button[contains(@class,'btn')]/i[contains(@class, 'ico-{Icon.ToKebabCase()}')]"; } else if (TestId != null) { xPath = $".//button[contains(@class,'btn') and @test-id='{TestId}']"; } else { throw new TestException("ClickButton. Attributes 'Text' or 'Icon' are required"); } browser.Click(control.GetElementByXPath(xPath)); }
void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) { Thread myThread = Thread.CurrentThread; try { // Make sure to abort the previous test's Run thread if it isn't done yet - this could happen if a test times out Thread threadToAbort; lock (m_runThreadLock) { threadToAbort = m_runThread; m_runThread = myThread; } AbortThread(threadToAbort); //Register configuration proxy to merge test configuration with VS ConfigurationProxy.Register(testElement.Storage); ITestAdapter realAdapter = GetTestAdapter(testElement); realAdapter.Run(testElement, testContext); } catch (ThreadAbortException) { // The agent-side adapter's thread that called this method may have already been aborted due to a timeout, so // don't send this exception back Thread.ResetAbort(); } finally { lock (m_runThreadLock) { if (m_runThread != null && m_runThread.ManagedThreadId == myThread.ManagedThreadId) { m_runThread = null; } } } }
/// <summary> /// Update test entries /// </summary> /// <param name="executionId"></param> /// <param name="parentExecutionId"></param> /// <param name="testElement"></param> /// <param name="parentTestElement"></param> private void UpdateTestEntries(Guid executionId, Guid parentExecutionId, ITestElement testElement, ITestElement parentTestElement) { TestEntry te = new TestEntry(testElement.Id, TestListCategory.UncategorizedResults.Id); te.ExecutionId = executionId; if (parentTestElement == null) { this.entries.TryAdd(executionId, te); } else if (parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) { te.ParentExecutionId = parentExecutionId; var parentTestEntry = GetTestEntry(parentExecutionId); if (parentTestEntry != null) { parentTestEntry.TestEntries.Add(te); } this.innerTestEntries.TryAdd(executionId, te); } }
private void AbortSingleTestResult(String message, ITestElement testElement, DateTime startTime) { TakeScreenShot("ScreenShot_SingleTestAborted"); String events = GetEvents(startTime, DateTime.Now); String abortMessage = String.Format("{0}{1}{2}", message, Environment.NewLine, events); TextTestResultMessage result = new TextTestResultMessage( m_runContext.RunConfig.TestRun.Id, testElement, abortMessage); TestResultAggregation testResult = new TestResultAggregation( Environment.MachineName, m_runContext.RunConfig.TestRun.Id, testElement); testResult.Outcome = TestOutcome.Aborted; m_runContext.ResultSink.AddResult(result); m_runContext.ResultSink.AddResult(testResult); }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { String xPath = String.Empty; if (!String.IsNullOrEmpty(Label)) { xPath = $".//label[contains(@class, 'checkbox')][normalize-space()={Label.XPathText()}]/input"; } else if (!String.IsNullOrEmpty(TestId)) { xPath = $".//label[contains(@class, 'checkbox')][@test-id='{TestId}']/input"; } // The <checkbox> is hidden. var scope = control.GetElementByXPath(xPath, checkVisibility: false); foreach (var step in Steps) { if (step is ElementStep es) { es.ElementRun(root, browser, scope); } } }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { String xPath = String.Empty; if (!String.IsNullOrEmpty(Label)) { xPath = $".//div[contains(@class, 'control-group')]/label/span[normalize-space()={Label.XPathText()}]/../../div[contains(@class, 'input-group')]/select"; } else if (!String.IsNullOrEmpty(TestId)) { xPath = $".//div[contains(@class, 'control-group')][@test-id='{TestId}']/div[contains(@class, 'input-group')]/select"; } // The <select> is hidden. A <select-wrapper> is shown instead. var scope = control.GetElementByXPath(xPath, checkVisibility: false); scope.Click(); Thread.Sleep(10); foreach (var step in Steps) { step.ElementRun(root, browser, scope); } }
/// <summary> /// Updates a test property. /// </summary> /// <param name="test">The test.</param> /// <param name="propertyToChange">The property to change.</param> public void UpdateTestProperty(ITestElement test, System.ComponentModel.PropertyDescriptor propertyToChange) { }
public GallioTestResult(Guid runId, ITestElement test) : base(Environment.MachineName, runId, test) { }
void ITimeoutTestAdapter.TestTimeout(ITestElement test) { ITimeoutTestAdapter realTimeoutAdapter = GetTestAdapter(test) as ITimeoutTestAdapter; if (realTimeoutAdapter != null) { realTimeoutAdapter.TestTimeout(test); } }
// and the following ones are here just to record the parameter names (missing in the delegates in MSVSAccess) public static MSVST4U_UnitTestResult New_MSVST4U_UnitTestResult_Standard(Guid runId, ITestElement test) { return MSVST4U_Tunnels.CreateTestResult(runId, test); }
public static MSVST4U_UnitTestResult New_MSVST4U_UnitTestResult_DataDriven(Guid runId, ITestElement test, TestOutcome outcome, TestResultCounter counters, MSVSTTC_TestResult[] innerResults) { return MSVST4U_Tunnels.CreateAggregateDataTestResult(runId, test, outcome, counters, innerResults); }
private bool RemoteCall( Action<TesteeTestAdapter> action, int retries = 2, bool restartVS = true, ITestElement currentTest = null, [CallerMemberName] string caller = null ) { var runContext = _runContext; if (runContext == null) { throw new InvalidOperationException(Resources.NoRunContext); } var runId = runContext.RunConfig.TestRun.Id; bool firstAttempt = true; while (retries-- > 0) { if (!_mockVs) { if (!firstAttempt) { // Send a message announcing that we are retrying the call SendMessage( runContext, string.Format( Resources.RetryRemoteCall, currentTest == null ? currentTest.HumanReadableId : caller ), currentTest ); } firstAttempt = false; if (!IsClientAlive()) { Close(); if (restartVS) { SendMessage(runContext, "Restarting VS", currentTest); Initialize(runContext); } else { SendMessage(runContext, Resources.NoClient, currentTest); return false; } } } var remote = _remote; if (remote == null) { return false; } try { action(remote); return true; } catch (RemotingException ex) { #if DEBUG var msg = string.Format(Resources.RemotingErrorDebug, caller, ex.Message, ex.ToString()); #else var msg = string.Format(Resources.RemotingError, caller, ex.Message); #endif SendMessage(runContext, msg, currentTest); // Close _remote and let EnsureClient bring it back if // requested by the caller var disposableRemote = Interlocked.Exchange(ref _remote, null) as IDisposable; if (disposableRemote != null) { try { disposableRemote.Dispose(); } catch (RemotingException) { } } } } throw new InvalidOperationException(Resources.NoClient); }
/// <summary> /// Creates a test result from a test step run. /// </summary> /// <param name="run">The test step run.</param> /// <param name="runId">The test run id.</param> /// <param name="test">The test element.</param> /// <returns>The test result.</returns> public static GallioTestResult CreateTestResult(TestStepRun run, Guid runId, ITestElement test) { return(CreateTestResult(run, runId, test, true)); }
public GallioTestResult(string computerName, Guid runId, ITestElement test) : base(computerName, runId, test) { }
/// <summary> /// IBaseAdapter method: called to execute a test. /// </summary> /// <param name="testElement">The test object to run</param> /// <param name="testContext">The Test conext for this test invocation</param> void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) { if (testElement.TestCategories.Contains(new TestCategoryItem("RestartVS"))) { CleanupHostSide(); InitHostSide(); } _hostSide.Run(testElement, testContext); }
void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) { ITestAdapter realAdapter = GetTestAdapter(testElement); realAdapter.Run(testElement, testContext); }
public void Run(ITestElement testElement, ITestContext testContext) { target.Run(testElement, testContext); }
/// <summary> /// IBaseAdapter method: called to execute a test. /// </summary> /// <param name="testElement">The test object to run</param> /// <param name="testContext">The Test conext for this test invocation</param> void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) { Trace.TraceInformation("Called MtaHostAdapter.Run"); ITestAdapter realAdapter = GetTestAdapter(testElement); RunOnMtaThread(() => { realAdapter.Run(testElement, testContext); }); }
public SingletonServiceWithDependency(IUnityContainer container, ITestElement element) { ContainerId = container.GetHashCode(); Element = element; }
private void PrePostHostCodeExecution(ITestElement testElement, ITestContext testContext, ExecutionType executionType) { Assembly testAssembly = null; Type testType = null; List<MethodInfo> preExecuteMethods = null; String currentMethod = String.Empty; String testClassName = String.Empty; object testObject = null; object[] parameters = new object[] { }; try { testAssembly = Assembly.LoadFrom(testElement.Storage); testClassName = GetTestClassName(testElement); testType = testAssembly.GetType(testClassName); preExecuteMethods = GetExecutionMethods(testType, executionType); if (preExecuteMethods.Count > 0) { if (HostExists()) CleanupHostSide(); testObject = Activator.CreateInstance(testType); foreach (var preExecuteMethod in preExecuteMethods) { currentMethod = preExecuteMethod.Name; preExecuteMethod.Invoke(testObject, parameters); } } } catch (Exception e) { String method = String.Empty; if (currentMethod != String.Empty) { method = " in Method: " + currentMethod; } else { method = "before method execution"; } HostProcessErrorHandler( String.Format("Pre-Host Code Execution Failed {0}. Error: {1}.", method, e.ToString()) , TestOutcome.Warning , false); } }
private static GallioTestResult CreateTestResult(TestStepRun run, Guid runId, ITestElement test, bool includeTestStepRunXml) { var result = new GallioTestResult(runId, test); result.TestName = run.Step.FullName; result.Outcome = GetOutcome(run.Result.Outcome); foreach (StructuredStream stream in run.TestLog.Streams) { string contents = stream.ToString(); if (stream.Name == MarkupStreamNames.DebugTrace) { result.DebugTrace += contents; } else if (stream.Name == MarkupStreamNames.ConsoleOutput) { result.StdOut += contents; } else if (stream.Name == MarkupStreamNames.ConsoleError) { result.StdErr += contents; } else if (stream.Name == MarkupStreamNames.Failures || stream.Name == MarkupStreamNames.Warnings) { result.ErrorMessage += contents; } else { result.DebugTrace += contents; } } result.SetTimings(run.StartTime, run.EndTime, run.Result.Duration); if (includeTestStepRunXml) { result.TestStepRunXml = TestStepRunToXml(run); } foreach (TestStepRun childRun in run.Children) { result.AddInnerResult(CreateTestResult(childRun, runId, test, false)); } return(result); }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { browser.Navigate(Url.ResolveValue(root)); Steps.ElementsRun(root, browser, control); }
private bool RemoteCall( Action <TesteeTestAdapter> action, int retries = 2, bool restartVS = true, ITestElement currentTest = null, [CallerMemberName] string caller = null ) { var runContext = _runContext; if (runContext == null) { throw new InvalidOperationException(Resources.NoRunContext); } var runId = runContext.RunConfig.TestRun.Id; bool firstAttempt = true; while (retries-- > 0) { if (!_mockVs) { if (!firstAttempt) { // Send a message announcing that we are retrying the call SendMessage( runContext, string.Format( Resources.RetryRemoteCall, currentTest == null ? currentTest.HumanReadableId : caller ), currentTest ); } firstAttempt = false; if (!IsClientAlive()) { Close(); if (restartVS) { SendMessage(runContext, "Restarting VS", currentTest); Initialize(runContext); } else { SendMessage(runContext, Resources.NoClient, currentTest); return(false); } } } var remote = _remote; if (remote == null) { return(false); } try { action(remote); return(true); } catch (RemotingException ex) { #if DEBUG var msg = string.Format(Resources.RemotingErrorDebug, caller, ex.Message, ex.ToString()); #else var msg = string.Format(Resources.RemotingError, caller, ex.Message); #endif SendMessage(runContext, msg, currentTest); // Close _remote and let EnsureClient bring it back if // requested by the caller var disposableRemote = Interlocked.Exchange(ref _remote, null) as IDisposable; if (disposableRemote != null) { try { disposableRemote.Dispose(); } catch (RemotingException) { } } } } throw new InvalidOperationException(Resources.NoClient); }
public Boolean IsSame(ITestElement elem) { return(_elem.Equals(elem.RawElement)); }
public static MSVST4U_UnitTestResult New_MSVST4U_UnitTestResult_DataDrivenRow(TestResultId id, ITestElement test, string dataRowInfo) { return MSVST4U_Tunnels.CreateDataTestResult(id, test, dataRowInfo); }
public abstract void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control);
public void Save(ITestElement[] tests, string location, ProjectData projectData) { target.Save(tests, location, projectData); }
public void Run(ITestElement testElement, ITestContext testContext) { if (!RemoteCall(r => r.Run(testElement, testContext), currentTest: testElement)) { testContext.ResultSink.AddResult(new TestResult(".", _runId, testElement) { Outcome = TestOutcome.NotRunnable }); } }
/// <summary> /// Returns true if the properties of the test are read only. /// </summary> /// <param name="test">The test.</param> /// <returns>True if the properties are read-only.</returns> public bool IsTestPropertiesReadOnly(ITestElement test) { return(true); }
/// <summary> /// Gets or creates test element. /// </summary> /// <param name="executionId"></param> /// <param name="parentExecutionId"></param> /// <param name="testType"></param> /// <param name="parentTestElement"></param> /// <param name="rockSteadyTestCase"></param> /// <returns>Trx test element</returns> private ITestElement GetOrCreateTestElement(Guid executionId, Guid parentExecutionId, TestType testType, ITestElement parentTestElement, ObjectModel.TestResult rockSteadyTestResult) { ITestElement testElement = parentTestElement; // For scenarios like data driven tests, test element is same as parent test element. if (parentTestElement != null && !parentTestElement.TestType.Equals(TrxLoggerConstants.OrderedTestType)) { return(testElement); } Guid testId = Converter.GetTestId(rockSteadyTestResult.TestCase); // Scenario for inner test case when parent test element is not present. var testName = rockSteadyTestResult.TestCase.DisplayName; if (parentTestElement == null && !string.IsNullOrEmpty(rockSteadyTestResult.DisplayName)) { testId = Guid.NewGuid(); testName = rockSteadyTestResult.DisplayName; } // Get test element testElement = GetTestElement(testId); // Create test element if (testElement == null) { testElement = Converter.ToTestElement(testId, executionId, parentExecutionId, testName, testType, rockSteadyTestResult.TestCase); testElements.TryAdd(testId, testElement); } return(testElement); }
/// <summary> /// IBaseAdapter method: called to execute a test. /// </summary> /// <param name="testElement">The test object to run</param> /// <param name="testContext">The Test conext for this test invocation</param> void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext) { _hostSide.Run(testElement, testContext); }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { ITestElement scope = FindScope(control); Steps.ElementsRun(root, browser, scope); }
public void Run(ITestElement testElement, ITestContext testContext) { var testAdapter = GetAdapter(testElement.Adapter); try { testAdapter.Run(testElement, testContext); } catch (Exception ex) { var message = new TextTestResultMessage( _runContext.RunConfig.TestRun.Id, testElement, ex.ToString() ); testContext.ResultSink.AddResult(message); } }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement control) { FindDialog(browser); }
public void Run(ITestElement testElement, ITestContext testContext) { var testAdapter = GetAdapter(testElement.Adapter); using (var screenRecorder = StartSceenRecorder(testElement, _runContext)) { try { testAdapter.Run(testElement, testContext); } catch (Exception ex) { var message = new TextTestResultMessage( _runContext.RunConfig.TestRun.Id, testElement, ex.ToString() ); testContext.ResultSink.AddResult(message); } if (screenRecorder != null && !string.IsNullOrEmpty(screenRecorder.Failure)) { var message = new TextTestResultMessage( _runContext.RunConfig.TestRun.Id, testElement, screenRecorder.Failure ); testContext.ResultSink.AddResult(message); } } }
/// <summary> /// Updates a custom test property. /// </summary> /// <param name="test">The test.</param> /// <param name="propertyToChange">The property to change.</param> public void UpdateTestCustomProperty(ITestElement test, string propertyToChange) { }
private ScreenRecorder StartSceenRecorder(ITestElement testElement, IRunContext runContext) { string screenCapture; if (!TryGetProperty(testElement, _runContext, VSTestProperties.ScreenCapture.Key, out screenCapture) || string.IsNullOrEmpty(screenCapture)) { return null; } try { if (!Path.IsPathRooted(screenCapture)) { screenCapture = Path.Combine( _runContext.RunConfig.TestRun.RunConfiguration.RunDeploymentOutDirectory, screenCapture ); } } catch (ArgumentException) { return null; } screenCapture = screenCapture.Replace("$id$", testElement.HumanReadableId); screenCapture = screenCapture.Replace("$date$", DateTime.Today.ToShortDateString()); var screenRecorder = new ScreenRecorder(screenCapture); string intervalString; int interval; if (TryGetProperty(testElement, runContext, VSTestProperties.ScreenCapture.IntervalKey, out intervalString) && int.TryParse(intervalString, out interval)) { screenRecorder.Interval = TimeSpan.FromMilliseconds(interval); } else { screenRecorder.Interval = TimeSpan.FromSeconds(1); } return screenRecorder; }
private XUnitTestRunner(Guid runId, ITestElement test) { _runId = runId; _test = test; }
private bool TryGetProperty( ITestElement testElement, IRunContext runContext, string propertyName, out string value ) { value = null; if (testElement.Properties.ContainsKey(propertyName)) { value = testElement.Properties[propertyName] as string; return value != null; } #if !VS11 var runProps = runContext.RunConfig.TestRun.RunConfiguration.TestSettingsProperties; return runProps.TryGetValue(propertyName, out value); #else return false; #endif }
public override void Save(ITestElement[] tests, string location, ProjectData projectData) { throw new NotSupportedException(); }
public override void ElementRun(IRootElement root, IWebBrowser browser, ITestElement elem) { elem.Click(); browser.WaitForComplete(); }