Exemplo n.º 1
0
            public override void VisitRun(ReportRun run)
            {
                string pretty = dox.Pretifier.PretifyTest(run.Name);

                writer.WriteLine("{0}  - {1}", this.tab, pretty);
                base.VisitRun(run);
            }
Exemplo n.º 2
0
        private void DisplaySelectedNodeResult()
        {
            this.textBox.Text = "";
            UnitTreeNode node = this.tree.TypeTree.SelectedNode as UnitTreeNode;

            if (node == null)
            {
                return;
            }

            ReportRun result = this.tree.TestDomains.GetResult(node);

            if (result != null)
            {
                switch (this.consoleStream)
                {
                case ConsoleStream.Out:
                    this.textBox.Text = result.ConsoleOut;
                    break;

                case ConsoleStream.Error:
                    this.textBox.Text = result.ConsoleError;
                    break;
                }
            }
            this.Refresh();
        }
            private void HandleTestFinish(RunPipe runPipe, ReportRun reportRun)
            {
                ITestCommand runPipeTestCommand;

                if (runPipeTestCommands.TryGetValue(runPipe, out runPipeTestCommand))
                {
                    ITestContext testContext = activeTestContexts[runPipeTestCommand];
                    activeTestContexts.Remove(runPipeTestCommand);

                    // Output all execution log contents.
                    // Note: ReportRun.Asserts is not actually populated by MbUnit so we ignore it.
                    if (reportRun.ConsoleOut.Length != 0)
                    {
                        testContext.LogWriter.ConsoleOutput.Write(reportRun.ConsoleOut);
                    }
                    if (reportRun.ConsoleError.Length != 0)
                    {
                        testContext.LogWriter.ConsoleError.Write(reportRun.ConsoleError);
                    }
                    foreach (ReportWarning warning in reportRun.Warnings)
                    {
                        testContext.LogWriter.Warnings.WriteLine(warning.Text);
                    }
                    if (reportRun.Exception != null)
                    {
                        testContext.LogWriter.Failures.WriteException(GetExceptionDataFromReportException(reportRun.Exception), "Exception");
                    }

                    // Finish up...
                    testContext.AddAssertCount(reportRun.AssertCount);
                    FinishStepWithReportRunResult(testContext, reportRun.Result);
                }

                progressMonitor.Worked(workUnit);
            }
Exemplo n.º 4
0
 void IReportsRepository.CreateReportRun(ReportRun reportRun)
 {
     using (var dc = CreateContext())
     {
         dc.SentReportEntities.InsertOnSubmit(reportRun.Map());
         dc.SubmitChanges();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Default constructor - initializes all fields to default values
 /// </summary>
 public RunPipeResultEventArgs(RunPipe pipe, ReportRun result)
     : base(pipe)
 {
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     this.result = result;
 }
Exemplo n.º 6
0
        private int SendReports(IEnumerable <EmployerReport> reports, DateTime startDate, DateTime endDate)
        {
            const string method = "SendReports";

            var allEmails = new List <TemplateEmail>();

            // Generate the emails for all reports.

            foreach (var definition in reports)
            {
                try
                {
                    var organisation   = (VerifiedOrganisation)_organisationsQuery.GetOrganisation(definition.ClientId);
                    var accountManager = _administratorsQuery.GetAdministrator(organisation.AccountManagerId);
                    var reportEmails   = RunReport(definition, organisation, startDate, endDate, accountManager);
                    allEmails.AddRange(reportEmails.Where(r => r != null));
                }
                catch (Exception ex)
                {
                    EventSource.Raise(Event.Error, method, string.Format("Failed to send report of type '{0}' (definition ID = {1})", definition.Type, definition.Id), ex, new StandardErrorHandler());
                }
            }

            // Combine multiple emails to the same receipients into one.

            var groupedEmails = CombineReports(allEmails);

            // Send the emails

            foreach (var email in groupedEmails)
            {
                _emailsCommand.TrySend(email);
            }
            DateTime sentTime = DateTime.Now;

            // Record that the reports were sent.

            foreach (var definition in reports)
            {
                // Rather than duplicate the logic which determines whether an email should have been sent
                // to the client or account manager here look through the emails collection to find it.

                var clientEmailAddress = (definition.SendToClient ? FindClientEmailAddress(allEmails, definition) : null);
                var accountManager     = (definition.SendToAccountManager ? FindAccountManager(allEmails, definition) : null);

                if (clientEmailAddress != null || accountManager != null)
                {
                    var sent = new ReportRun {
                        ReportId = definition.Id, SentTime = sentTime, PeriodStart = startDate, PeriodEnd = endDate, SentToAccountManagerId = accountManager == null ? (Guid?)null : accountManager.Id, SentToClientEmail = clientEmailAddress
                    };
                    _employerReportsCommand.CreateReportRun(sent);
                }
            }

            return(groupedEmails.Count);
        }
Exemplo n.º 7
0
        private bool ShouldSelectConnection(TfsKnownConnection knownConn, ReportRun lastReportRun)
        {
            if (lastReportRun == null)
            {
                return(false);
            }
            var select = knownConn.Id == lastReportRun.ConnectionId;

            return(select);
        }
Exemplo n.º 8
0
        public void Skip(Exception ex)
        {
            if (ex == null)
            {
                throw new ArgumentNullException("ex");
            }

            this.Start();
            this.result = ReportRun.Skip(this.Pipe, ex);
            this.Skip();
        }
Exemplo n.º 9
0
        public override bool Filter(RunPipe pipe)
        {
            ReportRun run = this.Explorer.GetRunByName(pipe.Name);

            if (run == null)
            {
                return(false);
            }

            return(run.Result != ReportRunResult.Success);
        }
Exemplo n.º 10
0
 public static SentReportEntity Map(this ReportRun reportRun)
 {
     return(new SentReportEntity
     {
         id = reportRun.Id,
         reportDefinitionId = reportRun.ReportId,
         sentTime = reportRun.SentTime,
         periodStart = reportRun.PeriodStart,
         periodEnd = reportRun.PeriodEnd,
         sentToAccountManagerId = reportRun.SentToAccountManagerId,
         sentToClientEmail = reportRun.SentToClientEmail,
     });
 }
Exemplo n.º 11
0
        public async Task Record(Guid knownConnId, string project, string iteration)
        {
            var filename = await GetFilename();

            var run = new ReportRun
            {
                ConnectionId = knownConnId,
                Project      = project,
                Iteration    = iteration,
            };

            var json = JsonConvert.SerializeObject(run);
            await File.WriteAllTextAsync(filename, json);
        }
Exemplo n.º 12
0
        void TestEngineIgnore(ReportRun run)
        {
            this.ignoreCount++;

            TestResult summary = new TestResult();

            summary.State      = TDF.TestState.Ignored;
            summary.TotalTests = this.testCount;
            summary.Name       = run.Name;
            summary.TimeSpan   = new TimeSpan(0, 0, 0, 0, (int)(run.Duration * 1000));

            testListener.WriteLine(String.Format("[ignored] {0}", run.Name), Category.Info);
            this.testListener.TestFinished(summary);
        }
Exemplo n.º 13
0
        public void Fail(ReportMonitor monitor, Exception ex)
        {
            if (monitor == null)
            {
                throw new ArgumentNullException("monitor");
            }
            if (ex == null)
            {
                throw new ArgumentNullException("ex");
            }

            this.Start();
            this.result = ReportRun.Failure(this.Pipe, monitor, ex);
            this.Failure();
        }
Exemplo n.º 14
0
        private void DisplaySelectedNodeResult()
        {
            // retreive current exceptoin
            this.exceptionTreeView.Nodes.Clear();
            this.textBox1.Text = "";
            UnitTreeNode node = this.tree.TypeTree.SelectedNode as UnitTreeNode;

            if (node == null)
            {
                return;
            }

            ReportRun result = this.Tree.TestDomains.GetResult(node);

            if (result != null && result.Result == ReportRunResult.Failure)
            {
                AddException(result.Exception);
            }
        }
Exemplo n.º 15
0
        void TestEngineSkip(ReportRun run)
        {
            this.skipCount++;

            TestResult summary = new TestResult();

            summary.State      = TDF.TestState.Ignored;
            summary.TotalTests = this.testCount;
            summary.Name       = run.Name;
            summary.TimeSpan   = new TimeSpan(0, 0, 0, 0, 0);

            if (run.Exception != null)
            {
                ReportException ex = run.Exception;

                summary.Message    = run.Exception.Message;
                summary.StackTrace = ex.ToString();
            }

            testListener.WriteLine(String.Format("[skipped] {0}", run.Name), Category.Info);
            this.testListener.TestFinished(summary);
        }
Exemplo n.º 16
0
        void TestEngineFailure(ReportRun run)
        {
            this.failureCount++;

            TestResult summary = new TestResult();

            summary.State      = TDF.TestState.Failed;
            summary.TotalTests = this.testCount;
            summary.Name       = run.Name;
            summary.TimeSpan   = new TimeSpan(0, 0, 0, 0, (int)(run.Duration * 1000));

            if (run.Exception != null)
            {
                ReportException ex = run.Exception;

                summary.Message    = run.Exception.Message;
                summary.StackTrace = ex.ToString();
            }

            testListener.WriteLine(String.Format("[failure] {0}", run.Name), Category.Info);
            this.testListener.TestFinished(summary);
        }
Exemplo n.º 17
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Skip);
 }
Exemplo n.º 18
0
 public void Ignore(RunPipe pipe, ReportRun result)
 {
     Writer.WriteLine("[ignored] {0}", pipe.Name);
 }
Exemplo n.º 19
0
        // MLS 12/21/05 - changing some of the messages below to give details more like the AutoRunner,
        //      although it still doesn't show all the details that the AutoRunner does.
        // TOOD: Refactor so that this is exactly like the AutoRunner, and remove duplicate code.

        public void Success(RunPipe pipe, ReportRun result)
        {
            Writer.WriteLine("[success] {0}", pipe.Name);
        }
Exemplo n.º 20
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
 }
Exemplo n.º 21
0
 public void Failure(RunPipe pipe, ReportRun result)
 {
     Writer.WriteLine("[failure] {0}: {1}", pipe.Name, result.Exception.Message);
 }
Exemplo n.º 22
0
 void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
 {
     HandleTestFinish(pipe, result);
 }
Exemplo n.º 23
0
 void IReportsCommand.CreateReportRun(ReportRun reportRun)
 {
     reportRun.Prepare();
     reportRun.Validate();
     _repository.CreateReportRun(reportRun);
 }
Exemplo n.º 24
0
 void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
 {
     HandleTestFinish(pipe, result);
 }
Exemplo n.º 25
0
            private void HandleTestFinish(RunPipe runPipe, ReportRun reportRun)
            {
                ITestCommand runPipeTestCommand;
                if (runPipeTestCommands.TryGetValue(runPipe, out runPipeTestCommand))
                {
                    ITestContext testContext = activeTestContexts[runPipeTestCommand];
                    activeTestContexts.Remove(runPipeTestCommand);

                    // Output all execution log contents.
                    // Note: ReportRun.Asserts is not actually populated by MbUnit so we ignore it.
                    if (reportRun.ConsoleOut.Length != 0)
                    {
                        testContext.LogWriter.ConsoleOutput.Write(reportRun.ConsoleOut);
                    }
                    if (reportRun.ConsoleError.Length != 0)
                    {
                        testContext.LogWriter.ConsoleError.Write(reportRun.ConsoleError);
                    }
                    foreach (ReportWarning warning in reportRun.Warnings)
                    {
                        testContext.LogWriter.Warnings.WriteLine(warning.Text);
                    }
                    if (reportRun.Exception != null)
                    {
                        testContext.LogWriter.Failures.WriteException(GetExceptionDataFromReportException(reportRun.Exception), "Exception");
                    }

                    // Finish up...
                    testContext.AddAssertCount(reportRun.AssertCount);
                    FinishStepWithReportRunResult(testContext, reportRun.Result);
                }

                progressMonitor.Worked(workUnit);
            }
Exemplo n.º 26
0
 public void ClearResult()
 {
     this.result       = null;
     this.abortPending = false;
 }
Exemplo n.º 27
0
 void IEmployerReportsCommand.CreateReportRun(ReportRun reportRun)
 {
     _reportsCommand.CreateReportRun(reportRun);
 }
Exemplo n.º 28
0
 public void Failure(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Failure);
 }
Exemplo n.º 29
0
        public void Run(Object fixture, bool IsExplicit)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }

            // create arguments...
            ArrayList args = new ArrayList();

            this.abortPending = false;
            this.monitor.Start();
            this.Start();

            Exception testException = null;

            foreach (RunInvokerVertex v in pipe.Invokers)
            {
                if (!v.HasInvoker)
                {
                    continue;
                }

                if (v.Invoker is ExplicitRunInvoker && !IsExplicit)
                {
                    testException = new IgnoreRunException("Explicit selection required.");
                }

                // if exception has already been thrown, execute non test only
                if (testException != null)
                {
                    if (!v.Invoker.Generator.IsTest)
                    {
                        // execute tear down code and drop exceptions
                        try
                        {
                            v.Invoker.Execute(fixture, args);
                        }
                        catch (Exception)
                        { }
                    }
                }
                else
                {
                    try
                    {
                        if (this.IsAbortPending)
                        {
                            continue;
                        }

                        if (v.Invoker.Generator.IsTest)
                        {
                            v.Invoker.Execute(fixture, args);
                        }
                        else
                        {
                            // can't re-use args for TearDown, or we get a parameter mismatch!
                            v.Invoker.Execute(fixture, new ArrayList());
                        }
                    }
                    catch (Exception ex)
                    {
                        testException = ex;
                    }
                }
            }

            this.monitor.Stop();

            // success
            if (testException == null)
            {
                this.result = ReportRun.Success(this.pipe, this.monitor);
                this.Success();
            }
            else
            {
                // get rid of TargetInvocationException
                if (testException.GetType() == typeof(TargetInvocationException))
                {
                    testException = testException.InnerException;
                }

                // check if ignoreexception
                if (testException is IgnoreRunException)
                {
                    this.result = ReportRun.Ignore(this.pipe, this.monitor);
                    this.Ignore();
                }
                // failure
                else
                {
                    this.result = ReportRun.Failure(this.pipe, this.monitor, testException);
                    this.Failure();
                }
            }
        }
Exemplo n.º 30
0
 public void Ignore(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Ignored);
 }