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);
            }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 11
0
        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]);
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 17
0
 public void Ignore(RunPipe pipe, ReportRun result)
 {
     Writer.WriteLine("[ignored] {0}", pipe.Name);
 }
Ejemplo n.º 18
0
 public void Failure(RunPipe pipe, ReportRun result)
 {
     Writer.WriteLine("[failure] {0}: {1}", pipe.Name, result.Exception.Message);
 }
Ejemplo n.º 19
0
 void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
 {
     HandleTestFinish(pipe, result);
 }
Ejemplo n.º 20
0
            void IRunPipeListener.Start(RunPipe pipe)
            {
                CheckCanceled();

                HandleTestStart(pipe);
            }
Ejemplo n.º 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);
        }
Ejemplo n.º 22
0
 public override bool Filter(RunPipe pipe)
 {
     return(true);
 }
Ejemplo n.º 23
0
 public void Start(RunPipe pipe)
 {
     this.OnChanged(pipe.Identifier, TestState.Running);
 }
Ejemplo n.º 24
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Skip);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 28
0
 void IRunPipeListener.Start(RunPipe pipe)
 {
     // find ficture
     ReportFixture fixture = AddFixture(pipe.Fixture);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 30
0
 public void Ignore(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Ignored);
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 32
0
 public void Failure(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Failure);
 }
Ejemplo n.º 33
0
 void IRunPipeListener.Start(RunPipe pipe)
 {
     // find ficture
     ReportFixture fixture = AddFixture(pipe.Fixture);
 }
Ejemplo n.º 34
0
		public void Start(RunPipe pipe)
		{
			this.OnChanged(pipe.Identifier,TestState.Running);
		}
Ejemplo n.º 35
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;
        }
Ejemplo n.º 36
0
        void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
        {
            ReportFixture fixture = AddFixture(pipe.Fixture);

            fixture.Runs.AddReportRun(result);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 39
0
 public override bool Filter(RunPipe pipe)
 {
     return true;
 }
Ejemplo n.º 40
0
 bool IRunPipeFilter.Filter(RunPipe runPipe)
 {
     return runPipeTestCommands.ContainsKey(runPipe);
 }
Ejemplo n.º 41
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
 }
Ejemplo n.º 42
0
        public void Failure(RunPipe pipe, ReportRun result)
        {
			this.OnChanged(pipe.Identifier,TestState.Failure);
		}
Ejemplo n.º 43
0
            void IRunPipeListener.Start(RunPipe pipe)
            {
                CheckCanceled();

                HandleTestStart(pipe);
            }
Ejemplo n.º 44
0
 public void Skip(RunPipe pipe, ReportRun result)
 {
     this.OnChanged(pipe.Identifier, TestState.Skip);
 }
Ejemplo n.º 45
0
 void IRunPipeListener.Skip(RunPipe pipe, ReportRun result)
 {
     HandleTestFinish(pipe, result);
 }
Ejemplo n.º 46
0
 public abstract bool Filter(RunPipe pipe);
Ejemplo n.º 47
0
            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;
            }
Ejemplo n.º 48
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);
            }
Ejemplo n.º 49
0
            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);
            }
Ejemplo n.º 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);
 }
Ejemplo n.º 51
0
 bool IRunPipeFilter.Filter(RunPipe runPipe)
 {
     return(runPipeTestCommands.ContainsKey(runPipe));
 }
Ejemplo n.º 52
0
 void IRunPipeListener.Success(RunPipe pipe, ReportRun result)
 {
     ReportFixture fixture = AddFixture(pipe.Fixture);
     fixture.Runs.AddReportRun(result);
 }
Ejemplo n.º 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;
 }