private void HandleTestStart(RunPipe runPipe)
            {
                ITestCommand runPipeTestCommand;

                if (!runPipeTestCommands.TryGetValue(runPipe, out runPipeTestCommand))
                {
                    return;
                }
                ITestCommand fixtureTestCommand;

                if (!fixtureTestCommands.TryGetValue(runPipe.Fixture, out fixtureTestCommand))
                {
                    return;
                }
                ITestContext fixtureTestContext;

                if (!activeTestContexts.TryGetValue(fixtureTestCommand, out fixtureTestContext))
                {
                    return;
                }

                progressMonitor.SetStatus(runPipeTestCommand.Test.Name);

                ITestContext runPipeTestContext = runPipeTestCommand.StartPrimaryChildStep(fixtureTestContext.TestStep);

                activeTestContexts.Add(runPipeTestCommand, runPipeTestContext);

                runPipeTestContext.LifecyclePhase = LifecyclePhases.Execute;
            }
            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);
            }
Beispiel #3
0
        public RunPipeCollection AllTestPipes()
        {
            if (this.graph.VerticesCount == 1)
            {
                // only the root vertex
                return(new RunPipeCollection());
            }
            DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(
                this.graph
                );

            // attach leaf recorder
            PredecessorRecorderVisitor pred = new PredecessorRecorderVisitor();

            dfs.RegisterPredecessorRecorderHandlers(pred);
            dfs.Compute(this.Root);

            // create pipies
            RunPipeCollection pipes =
                new RunPipeCollection();

            foreach (EdgeCollection edges in pred.AllPaths())
            {
                RunPipe pipe = new RunPipe(this.Fixture);

                foreach (IEdge e in edges)
                {
                    pipe.Invokers.Add((RunInvokerVertex)e.Target);
                }

                pipes.Add(pipe);
            }
            return(pipes);
        }
Beispiel #4
0
 /// <summary>
 /// Adds an instance of type RunPipe to the end of this RunPipeCollection.
 /// </summary>
 /// <param name="value">
 /// The RunPipe to be added to the end of this RunPipeCollection.
 /// </param>
 public void Add(RunPipe value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     this.List.Add(value);
 }
        public override bool Filter(RunPipe pipe)
        {
            ReportRun run = this.Explorer.GetRunByName(pipe.Name);
            if (run == null)
                return false;

            return run.Result != ReportRunResult.Success;
        }
 public override bool Filter(RunPipe pipe)
 {
     foreach (RunInvokerVertex invoker in pipe.Invokers)
     {
         if (!invoker.HasInvoker)
             continue;
         if (invoker.Invoker.ContainsMemberInfo(this.MemberInfo))
             return true;
     }
     return false;
 }
Beispiel #7
0
        public override bool Filter(RunPipe pipe)
        {
            ReportRun run = this.Explorer.GetRunByName(pipe.Name);

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

            return(run.Result != ReportRunResult.Success);
        }
Beispiel #8
0
        public static ReportRun Skip(RunPipe pipe, Exception ex)
        {
            ReportRun run = new ReportRun();

            run.Result      = ReportRunResult.Skip;
            run.Name        = pipe.Name;
            run.Duration    = 0;
            run.Memory      = 0;
            run.AssertCount = MbUnit.Framework.Assert.AssertCount;
            run.Exception   = ReportException.FromException(ex);

            MbUnit.Framework.Assert.FlushWarnings(run);

            return(run);
        }
Beispiel #9
0
        public static ReportRun Success(RunPipe pipe, ReportMonitor monitor)
        {
            ReportRun run = new ReportRun();
            run.ConsoleOut = monitor.Consoler.Out;
            run.ConsoleError = monitor.Consoler.Error;
            run.Result = ReportRunResult.Success;
            run.Name = pipe.Name;
            run.AssertCount = MbUnit.Framework.Assert.AssertCount;
            run.Duration = monitor.Timer.Duration;
            run.Memory = monitor.Memorizer.Usage;

            MbUnit.Framework.Assert.FlushWarnings(run);

            return run;
        }
Beispiel #10
0
 public override bool Filter(RunPipe pipe)
 {
     foreach (RunInvokerVertex invoker in pipe.Invokers)
     {
         if (!invoker.HasInvoker)
         {
             continue;
         }
         if (invoker.Invoker.ContainsMemberInfo(this.MemberInfo))
         {
             return(true);
         }
     }
     return(false);
 }
        private TestTreeNode addFixtureNode(
            GuidTestTreeNodeDictionary nodes,
            TestTreeNode parentNode,
            RunPipeStarter pipeStarter)
        {
            RunPipe pipe = pipeStarter.Pipe;

            if (!this.fixtureNodes.Contains(pipe.FixtureName))
            {
                TestTreeNode fixtureNode = new TestTreeNode(pipe.FixtureName, TestNodeType.Fixture);
                this.fixtureNodes.Add(pipe.FixtureName, fixtureNode);
                nodes.Add(fixtureNode);
                parentNode.Nodes.Add(fixtureNode);
            }
            return((TestTreeNode)this.fixtureNodes[pipe.FixtureName]);
        }
Beispiel #12
0
        private TestTreeNode addFixtureNode(GuidTestTreeNodeDictionary nodes,
                                            TestTreeNode parentNode,
                                            RunPipeStarter pipeStarter)
        {
            RunPipe pipe = pipeStarter.Pipe;
            string  key  = pipe.FixtureName + parentNode.FullPath;

            if (!this.fixtureNodes.Contains(key))
            {
                TestTreeNode fixtureNode = new TestTreeNode(pipe.FixtureName, TestNodeType.Fixture);
                this.fixtureNodes.Add(key, fixtureNode);
                nodes.Add(fixtureNode);
                parentNode.Nodes.Add(fixtureNode);
            }
            return((TestTreeNode)this.fixtureNodes[key]);
        }
Beispiel #13
0
        public static ReportRun Failure(RunPipe pipe, ReportMonitor monitor, Exception ex)
        {
            ReportRun run = new ReportRun();
            run.ConsoleOut = monitor.Consoler.Out;
            run.ConsoleError = monitor.Consoler.Error;
            run.Result = ReportRunResult.Failure;
            run.Name = pipe.Name;
            run.AssertCount = MbUnit.Framework.Assert.AssertCount;
            run.Duration = monitor.Timer.Duration;
            run.Memory = monitor.Memorizer.Usage;
            run.Exception = ReportException.FromException(ex);

            MbUnit.Framework.Assert.FlushWarnings(run);

            return run;
        }
Beispiel #14
0
        public static ReportRun Ignore(RunPipe pipe, ReportMonitor monitor)
        {
            ReportRun run = new ReportRun();

            run.ConsoleOut   = monitor.Consoler.Out;
            run.ConsoleError = monitor.Consoler.Error;
            run.Result       = ReportRunResult.Ignore;
            run.Name         = pipe.Name;
            run.AssertCount  = MbUnit.Framework.Assert.AssertCount;
            run.Duration     = monitor.Timer.Duration;
            run.Memory       = monitor.Memorizer.Usage;

            MbUnit.Framework.Assert.FlushWarnings(run);

            return(run);
        }
Beispiel #15
0
        private TestTreeNode addFixtureNode(GuidTestTreeNodeDictionary nodes,
                                            TestTreeNode parentNode,
                                            RunPipeStarter pipeStarter)
        {
            RunPipe      pipe        = pipeStarter.Pipe;
            TestTreeNode fixtureNode = this.fixtureNodes[pipe.Fixture.Type] as TestTreeNode;

            if (fixtureNode != null)
            {
                return(fixtureNode);
            }

            fixtureNode = new TestTreeNode(pipe.FixtureName, TestNodeType.Fixture);
            this.fixtureNodes.Add(pipe.Fixture.Type, fixtureNode);
            nodes.Add(fixtureNode);
            parentNode.Nodes.Add(fixtureNode);

            return(fixtureNode);
        }
Beispiel #16
0
        private TestTreeNode addNamespaceNodes(GuidTestTreeNodeDictionary nodes, RunPipeStarter pipeStarter)
        {
            RunPipe pipe = pipeStarter.Pipe;
            string  ns   = "";

            TestTreeNode parent     = this.parentNode;
            string       namespace_ = pipe.FixtureType.Namespace;

            if (namespace_ == null || namespace_.Length == 0)
            {
                namespace_ = "";
            }
            foreach (string name in namespace_.Split('.'))
            {
                if (ns.Length == 0)
                {
                    ns += name;
                }
                else
                {
                    ns += "." + name;
                }

                if (!this.namespaceNodes.Contains(ns))
                {
                    TestTreeNode node = new TestTreeNode(name, TestNodeType.Category);

                    this.namespaceNodes.Add(ns, node);
                    parent.Nodes.Add(node);
                    nodes.Add(node);
                    parent = node;
                }
                else
                {
                    parent = (TestTreeNode)this.namespaceNodes[ns];
                }
            }

            return(parent);
        }
Beispiel #17
0
 public void Ignore(RunPipe pipe, ReportRun result)
 {
     Writer.WriteLine("[ignored] {0}", pipe.Name);
 }
Beispiel #18
0
 public void Failure(RunPipe pipe, ReportRun result)
 {
     Writer.WriteLine("[failure] {0}: {1}", pipe.Name, result.Exception.Message);
 }
 void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
 {
     HandleTestFinish(pipe, result);
 }
            void IRunPipeListener.Start(RunPipe pipe)
            {
                CheckCanceled();

                HandleTestStart(pipe);
            }
Beispiel #21
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);
        }
Beispiel #22
0
 public override bool Filter(RunPipe pipe)
 {
     return(true);
 }
Beispiel #23
0
 public void Start(RunPipe pipe)
 {
     this.OnChanged(pipe.Identifier, TestState.Running);
 }
Beispiel #24
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Skip);
 }
Beispiel #25
0
        public static ReportRun Skip(RunPipe pipe, Exception ex)
        {
            ReportRun run = new ReportRun();
            run.Result = ReportRunResult.Skip;
            run.Name = pipe.Name;
            run.Duration = 0;
            run.Memory = 0;
            run.AssertCount = MbUnit.Framework.Assert.AssertCount;
            run.Exception = ReportException.FromException(ex);

            MbUnit.Framework.Assert.FlushWarnings(run);

            return run;
        }
 /// <summary>
 /// Determines whether a specfic RunPipe value is in this RunPipeCollection.
 /// </summary>
 /// <param name="value">
 /// The RunPipe value to locate in this RunPipeCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this RunPipeCollection;
 /// false otherwise.
 /// </returns>
 public bool Contains(RunPipe value)
 {
     return this.List.Contains(value);
 }
 /// <summary>
 /// Removes the first occurrence of a specific RunPipe from this RunPipeCollection.
 /// </summary>
 /// <param name="value">
 /// The RunPipe value to remove from this RunPipeCollection.
 /// </param>
 public void Remove(RunPipe value)
 {
     this.List.Remove(value);
 }
Beispiel #28
0
 void IRunPipeListener.Start(RunPipe pipe)
 {
     // find ficture
     ReportFixture fixture = AddFixture(pipe.Fixture);
 }
Beispiel #29
0
 /// <summary>
 /// Initializes a test initially without a parent.
 /// </summary>
 /// <param name="name">The name of the component.</param>
 /// <param name="codeElement">The point of definition, or null if none.</param>
 /// <param name="fixture">The MbUnit v2 fixture, or null if none.</param>
 /// <param name="runPipe">The MbUnit v2 run pipe, or null if none.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> is null.</exception>
 public MbUnit2Test(string name, ICodeElementInfo codeElement, Fixture fixture, RunPipe runPipe)
     : base(name, codeElement)
 {
     this.fixture = fixture;
     this.runPipe = runPipe;
 }
Beispiel #30
0
 public void Ignore(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Ignored);
 }
Beispiel #31
0
 /// <summary>
 /// Determines whether a specfic RunPipe value is in this RunPipeCollection.
 /// </summary>
 /// <param name="value">
 /// The RunPipe value to locate in this RunPipeCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this RunPipeCollection;
 /// false otherwise.
 /// </returns>
 public bool Contains(RunPipe value)
 {
     return(this.List.Contains(value));
 }
Beispiel #32
0
 public void Failure(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Failure);
 }
 void IRunPipeListener.Start(RunPipe pipe)
 {
     // find ficture
     ReportFixture fixture = AddFixture(pipe.Fixture);
 }
Beispiel #34
0
		public void Start(RunPipe pipe)
		{
			this.OnChanged(pipe.Identifier,TestState.Running);
		}
        public RunPipeCollection AllTestPipes()
        {
            if (this.graph.VerticesCount == 1)
            {
                // only the root vertex
                return new RunPipeCollection();
            }
            DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(
                this.graph
                );

            // attach leaf recorder
            PredecessorRecorderVisitor pred = new PredecessorRecorderVisitor();
            dfs.RegisterPredecessorRecorderHandlers(pred);
            dfs.Compute(this.Root);

            // create pipies
            RunPipeCollection pipes =
                new RunPipeCollection();

            foreach(EdgeCollection edges in pred.AllPaths())
            {
                RunPipe pipe = new RunPipe(this.Fixture);

                foreach(IEdge e in edges)
                {
                    pipe.Invokers.Add((RunInvokerVertex)e.Target);
                }

                pipes.Add(pipe);
            }
            return pipes;
        }
Beispiel #36
0
        void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
        {
            ReportFixture fixture = AddFixture(pipe.Fixture);

            fixture.Runs.AddReportRun(result);
        }
Beispiel #37
0
        public void Ignore(RunPipe pipe, ReportRun result)
        {
			this.OnChanged(pipe.Identifier,TestState.Ignored);
		}
 /// <summary>
 /// Adds an instance of type RunPipe to the end of this RunPipeCollection.
 /// </summary>
 /// <param name="value">
 /// The RunPipe to be added to the end of this RunPipeCollection.
 /// </param>
 public void Add(RunPipe value)
 {
     if (value == null)
         throw new ArgumentNullException("value");
     this.List.Add(value);
 }
Beispiel #39
0
 public override bool Filter(RunPipe pipe)
 {
     return true;
 }
 bool IRunPipeFilter.Filter(RunPipe runPipe)
 {
     return runPipeTestCommands.ContainsKey(runPipe);
 }
Beispiel #41
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
 }
Beispiel #42
0
        public void Failure(RunPipe pipe, ReportRun result)
        {
			this.OnChanged(pipe.Identifier,TestState.Failure);
		}
            void IRunPipeListener.Start(RunPipe pipe)
            {
                CheckCanceled();

                HandleTestStart(pipe);
            }
Beispiel #44
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Skip);
 }
 void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
 {
     HandleTestFinish(pipe, result);
 }
Beispiel #46
0
 public abstract bool Filter(RunPipe pipe);
            private void HandleTestStart(RunPipe runPipe)
            {
                ITestCommand runPipeTestCommand;
                if (!runPipeTestCommands.TryGetValue(runPipe, out runPipeTestCommand))
                    return;
                ITestCommand fixtureTestCommand;
                if (!fixtureTestCommands.TryGetValue(runPipe.Fixture, out fixtureTestCommand))
                    return;
                ITestContext fixtureTestContext;
                if (!activeTestContexts.TryGetValue(fixtureTestCommand, out fixtureTestContext))
                    return;

                progressMonitor.SetStatus(runPipeTestCommand.Test.Name);

                ITestContext runPipeTestContext = runPipeTestCommand.StartPrimaryChildStep(fixtureTestContext.TestStep);
                activeTestContexts.Add(runPipeTestCommand, runPipeTestContext);

                runPipeTestContext.LifecyclePhase = LifecyclePhases.Execute;
            }
            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);
            }
            private void Initialize()
            {
                progressMonitor.Canceled += HandleCanceled;
                progressMonitor.SetStatus(Resources.MbUnit2TestController_InitializingMbUnitTestRunner);

                int totalWork = 1;

                if (fixtureExplorer.HasAssemblySetUp)
                {
                    totalWork += 1;
                }
                if (fixtureExplorer.HasAssemblyTearDown)
                {
                    totalWork += 1;
                }

                // Build a reverse mapping from types and run-pipes to tests.
                includedFixtureTypes = new HashSet <Type>();
                fixtureTestCommands  = new Dictionary <Fixture, ITestCommand>();
                runPipeTestCommands  = new Dictionary <RunPipe, ITestCommand>();
                activeTestContexts   = new Dictionary <ITestCommand, ITestContext>();

                bool isExplicit = false;

                foreach (ITestCommand testCommand in testCommands)
                {
                    if (testCommand.IsExplicit)
                    {
                        isExplicit = true;
                    }

                    MbUnit2Test test    = (MbUnit2Test)testCommand.Test;
                    Fixture     fixture = test.Fixture;
                    RunPipe     runPipe = test.RunPipe;

                    if (fixture == null)
                    {
                        assemblyTestCommand = testCommand;
                    }
                    else if (runPipe == null)
                    {
                        includedFixtureTypes.Add(fixture.Type);
                        fixtureTestCommands[fixture] = testCommand;

                        if (fixture.HasSetUp)
                        {
                            totalWork += 1;
                        }
                        if (fixture.HasTearDown)
                        {
                            totalWork += 1;
                        }
                    }
                    else
                    {
                        runPipeTestCommands[runPipe] = testCommand;
                        totalWork += 1;
                    }
                }

                // Set options
                IsExplicit    = isExplicit;
                FixtureFilter = this;
                RunPipeFilter = this;

                workUnit = 1.0 / totalWork;
                progressMonitor.Worked(workUnit);
            }
Beispiel #50
0
 /// <summary>
 /// Removes the first occurrence of a specific RunPipe from this RunPipeCollection.
 /// </summary>
 /// <param name="value">
 /// The RunPipe value to remove from this RunPipeCollection.
 /// </param>
 public void Remove(RunPipe value)
 {
     this.List.Remove(value);
 }
 bool IRunPipeFilter.Filter(RunPipe runPipe)
 {
     return(runPipeTestCommands.ContainsKey(runPipe));
 }
 void IRunPipeListener.Success(RunPipe pipe, ReportRun result)
 {
     ReportFixture fixture = AddFixture(pipe.Fixture);
     fixture.Runs.AddReportRun(result);
 }
Beispiel #53
0
 /// <summary>
 /// Initializes a test initially without a parent.
 /// </summary>
 /// <param name="name">The name of the component.</param>
 /// <param name="codeElement">The point of definition, or null if none.</param>
 /// <param name="fixture">The MbUnit v2 fixture, or null if none.</param>
 /// <param name="runPipe">The MbUnit v2 run pipe, or null if none.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> is null.</exception>
 public MbUnit2Test(string name, ICodeElementInfo codeElement, Fixture fixture, RunPipe runPipe)
     : base(name, codeElement)
 {
     this.fixture = fixture;
     this.runPipe = runPipe;
 }