internal void Execute(Context ctx) { try { var tsea = new TestStepEventArgs(ctx.CurrentTestStage, ctx.TestName, TypeName); ctx.BizUnitObject.OnTestStepStart(tsea); if (null != _stepConfig) { _testStep.Execute(_stepConfig, ctx); } else { _testStepBuilder.PrepareStepForExecution(ctx); _testStepBuilder.PrepareSubStepsForExecution(ctx); ctx.BizUnitObject.OnTestStepStart(tsea); _testStepBuilder.TestStepOM.Validate(ctx); _testStepBuilder.TestStepOM.Execute(ctx); } ctx.BizUnitObject.OnTestStepStop(tsea); } catch (Exception executionException) { ExecuteException = executionException; throw; } }
private void ExecuteSteps(XmlNodeList steps) { if (null == steps) { return; } foreach (XmlNode stepConfig in steps) { bool runConcurrently = false; XmlNode assemblyPath = stepConfig.SelectSingleNode("@assemblyPath"); XmlNode typeName = stepConfig.SelectSingleNode("@typeName"); XmlNode runConcurrentlyNode = stepConfig.SelectSingleNode("@runConcurrently"); if (null != runConcurrentlyNode) { runConcurrently = Convert.ToBoolean(runConcurrentlyNode.Value); } object obj = CreateStep(typeName.Value, assemblyPath.Value); ITestStep step = obj as ITestStep; try { // Should this step be executed concurrently? if (runConcurrently) { this.logger.WriteLine(string.Format("\nStep: {0} started c o n c u r r e n t l y @ {1}", typeName.Value, GetNow())); Interlocked.Increment(ref this.inflightQueueDepth); ThreadPool.QueueUserWorkItem(new WaitCallback(this.WorkerThreadThunk), new ConcurrentTestStepWrapper(step, stepConfig, this, typeName.Value)); } else { this.logger.WriteLine(string.Format("\nStep: {0} started @ {1} ", typeName.Value, GetNow())); step.Execute(stepConfig, context); } } catch (Exception e) { this.logger.LogException(e); throw; } if (!runConcurrently) { this.logger.WriteLine(string.Format("Step: {0} ended @ {1}", typeName.Value, GetNow())); } FlushConcurrentQueue(false); } FlushConcurrentQueue(true); }