Exemplo n.º 1
0
        public void OnSpecificationEnd(Runner.SpecificationInfo specification, Specifications.Result result)
        {
            Result utilityResult;

            if (result.Status == Specifications.Status.Ignored)
            {
                utilityResult = Result.Ignored();
            }
            else if (result.Status == Specifications.Status.NotImplemented)
            {
                utilityResult = Result.NotImplemented();
            }
            else if (result.Status == Specifications.Status.Failing)
            {
                utilityResult = Result.Failure(GetExceptionResult(result.Exception));
            }
            else
            {
                utilityResult = Result.Pass();
            }

            foreach (var key in result.Supplements.Keys)
            {
                utilityResult.Supplements[key] = result.Supplements[key];
            }

            listener.OnSpecificationEnd(new SpecificationInfo(specification.Leader, specification.Name, specification.ContainingType, specification.FieldName), utilityResult);
        }
Exemplo n.º 2
0
 static List <Result> FailSpecification(ISpecificationRunListener listener, Specification specification, Result result)
 {
     listener.OnSpecificationStart(specification.GetInfo());
     listener.OnSpecificationEnd(specification.GetInfo(), result);
     return(new List <Result> {
         result
     });
 }
Exemplo n.º 3
0
        public void OnSpecificationEnd(SpecificationInfo specification, Result result)
        {
            if (listenFor != null && !listenFor.Equals(specification.ToVisualStudioTestIdentifier(currentContext)))
            {
                return;
            }

            runListener.OnSpecificationEnd(specification, result);
        }
        public Result Run(Specification specification)
        {
            _listener.OnSpecificationStart(specification.GetInfo());
            var result = specification.Verify();

            result = _resultSupplementers.Aggregate(result, (r, supplement) => supplement.SupplementResult(r));
            _listener.OnSpecificationEnd(specification.GetInfo(), result);

            return(result);
        }
    private IEnumerable<Result> FailSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, Result result)
    {
      var results = new List<Result>();
      foreach (var specification in context.Specifications)
      {
        listener.OnSpecificationStart(specification.GetInfo());
        listener.OnSpecificationEnd(specification.GetInfo(), result);
        results.Add(result);
      }

      return results;
    }
    private static IEnumerable<Result> FailSpecifications(Context context, ISpecificationRunListener listener, Result result, IEnumerable<ISupplementSpecificationResults> resultSupplementers)
    {
      result = resultSupplementers.Aggregate(result, (r, supplement) => supplement.SupplementResult(r));

      var results = new List<Result>();
      foreach (var specification in context.Specifications)
      {
        listener.OnSpecificationStart(specification.GetInfo());
        listener.OnSpecificationEnd(specification.GetInfo(), result);

        results.Add(result);
      }

      return results;
    }
Exemplo n.º 7
0
        private void OnListenEvent(string value)
        {
            using (var stringReader = new StringReader(value)) {
                XDocument doc     = XDocument.Load(stringReader);
                XElement  element = doc.XPathSelectElement("/listener/*");

                switch (element.Name.ToString())
                {
                case "onassemblystart":
                    _runListener.OnAssemblyStart(AssemblyInfo.Parse(element.XPathSelectElement("//onassemblystart/*").ToString()));
                    break;

                case "onassemblyend":
                    _runListener.OnAssemblyEnd(AssemblyInfo.Parse(element.XPathSelectElement("//onassemblyend/*").ToString()));
                    break;

                case "onrunstart":
                    _runListener.OnRunStart();
                    break;

                case "onrunend":
                    _runListener.OnRunEnd();
                    break;

                case "oncontextstart":
                    _runListener.OnContextStart(ContextInfo.Parse(element.XPathSelectElement("//oncontextstart/*").ToString()));
                    break;

                case "oncontextend":
                    _runListener.OnContextEnd(ContextInfo.Parse(element.XPathSelectElement("//oncontextend/*").ToString()));
                    break;

                case "onspecificationstart":
                    _runListener.OnSpecificationStart(SpecificationInfo.Parse(element.XPathSelectElement("//onspecificationstart/*").ToString()));
                    break;

                case "onspecificationend":
                    _runListener.OnSpecificationEnd(
                        SpecificationInfo.Parse(element.XPathSelectElement("//onspecificationend/specificationinfo").ToString()),
                        Result.Parse(element.XPathSelectElement("//onspecificationend/result").ToString()));
                    break;

                case "onfatalerror":
                    _runListener.OnFatalError(ExceptionResult.Parse(element.XPathSelectElement("//onfatalerror/*").ToString()));
                    break;
                }
            }
        }
Exemplo n.º 8
0
        private static IEnumerable <Result> FailSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, Result result, IEnumerable <ISupplementSpecificationResults> resultSupplementers)
        {
            result = resultSupplementers.Aggregate(result, (r, supplement) => supplement.SupplementResult(r));

            var results = new List <Result>();

            foreach (var specification in context.Specifications)
            {
                listener.OnSpecificationStart(specification.GetInfo());
                listener.OnSpecificationEnd(specification.GetInfo(), result);

                results.Add(result);
            }

            return(results);
        }
        public static void Run(this ISpecificationRunListener adapter, AssemblyInfo assemblyInfo,
                               SpecificationInfo specificationInfo, Result failure, ExceptionResult exceptionResult,
                               ContextInfo contexInfo)
        {
            adapter.OnAssemblyStart(assemblyInfo);
            adapter.OnAssemblyEnd(assemblyInfo);

            adapter.OnSpecificationStart(specificationInfo);
            adapter.OnSpecificationEnd(specificationInfo, failure);

            adapter.OnFatalError(exceptionResult);

            adapter.OnContextStart(contexInfo);
            adapter.OnContextEnd(contexInfo);

            adapter.OnRunStart();
            adapter.OnRunEnd();
        }
        public override void OnSpecificationEnd(SpecificationInfo specification, Result result)
        {
            _listener.OnSpecificationEnd(specification, result);

            ITestContext testContext = _contextsBySpec[specification.Name];

            testContext.LifecyclePhase = LifecyclePhases.Finishing;

            TestOutcome outcome;
            TimeSpan?   span = null;

            if (result.Status == Status.NotImplemented)
            {
                TestLog.Warnings.WriteLine("{0} ({1})", specification.Name, "NOT IMPLEMENTED");
                TestLog.Warnings.Flush();

                outcome = TestOutcome.Pending;
                span    = new TimeSpan(0);
            }
            else if (result.Status == Status.Ignored)
            {
                TestLog.Warnings.WriteLine("{0} ({1})", specification.Name, "IGNORED");
                TestLog.Warnings.Flush();

                outcome = TestOutcome.Ignored;
                span    = new TimeSpan(0);
            }
            else if (result.Passed)
            {
                outcome = TestOutcome.Passed;
            }
            else
            {
                TestLog.Failures.WriteException(Convert(result.Exception));
                TestLog.Failures.Flush();

                outcome = TestOutcome.Failed;
            }

            testContext.FinishStep(outcome, span);
            _outcome = _outcome.CombineWith(outcome);

            _progressMonitor.Worked(1);
        }
Exemplo n.º 11
0
 static List<Result> FailSpecification(ISpecificationRunListener listener, Specification specification, Result result)
 {
   listener.OnSpecificationStart(specification.GetInfo());
   listener.OnSpecificationEnd(specification.GetInfo(), result);
   return new List<Result> { result };
 }
 public void OnSpecificationEnd(SpecificationInfo specification, Result result)
 {
     _listener.OnSpecificationEnd(specification, result);
 }
Exemplo n.º 13
0
 public virtual void OnSpecificationEnd(SpecificationInfo specificationInfo, Result result)
 {
     _runListener.OnSpecificationEnd(specificationInfo, result);
 }