public void Init()
		{
			testRunnerEvents = new MockTestRunnerEvents();
			testRunnerEvents.TestStepFinished += delegate (object source, TestStepFinishedEventArgs e) {
				testStepFinishedEventArgs = e;
			};
		}
        private void LogTestCaseFinished(TestStepFinishedEventArgs e)
        {
            var testCase = testCaseFactory.GetTestCase(e.Test);

              var testResult = testResultFactory.BuildTestResult(e.Test, e.TestStepRun, testCase);

              executionRecorder.RecordEnd(testCase, testResult.Outcome);
              executionRecorder.RecordResult(testResult);
        }
        void Events_TestStepFinished(object sender, TestStepFinishedEventArgs e)
        {
            Debug.WriteLine("TestStep Finished");
            Debug.WriteLine(e.Test.FullName);
            Debug.WriteLine(String.Format("TestStepRun.Step.FullName: {0}", e.TestStepRun.Step.FullName));
            Debug.WriteLine(string.Format("  IsTestCase = {0}", e.Test.IsTestCase));
            Debug.WriteLine(string.Format("  Test Result for {0}: {1}", e.TestStepRun.Step.Name, e.TestStepRun.Result.Outcome));
            Debug.WriteLine(string.Format("  CodeLocation {0}", e.TestStepRun.Step.CodeLocation.Path));
            Debug.WriteLine(string.Format("  CodeReference {0}", e.TestStepRun.Step.CodeReference.Kind));
            foreach (string key in e.TestStepRun.Step.Metadata.Keys)
            {
                Debug.WriteLine(string.Format("  {0}= {1}", key, e.TestStepRun.Step.Metadata[key][0]));
            }

            if (e.TestStepRun.Step.CodeReference.Kind == Gallio.Common.Reflection.CodeReferenceKind.Assembly)
            {
                exporter.RetrieveTestFixture(e.TestStepRun.Step.FullName, e.TestStepRun.Step.CodeLocation.Path);
            }
            Debug.WriteLine("---------------------------------------");

        }
示例#4
0
 /// <summary>
 /// Logs a message about a test case that has finished.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method is not called for test steps that have <see cref="TestStep.IsTestCase"/> set to false.
 /// </para>
 /// </remarks>
 /// <param name="e">The event.</param>
 protected virtual void LogTestCaseFinished(TestStepFinishedEventArgs e)
 {
     LogTest(e);
 }
示例#5
0
 /// <summary>
 /// Logs a message about a non-test case that has finished with some problem that
 /// may have prevented other test cases from running correctly.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This method is not called for steps within test cases.
 /// </para>
 /// <para>
 /// This method is not called for test steps that have <see cref="TestStep.IsTestCase"/> set to true.
 /// </para>
 /// </remarks>
 /// <param name="e">The event.</param>
 protected virtual void LogNonTestCaseProblem(TestStepFinishedEventArgs e)
 {
     LogTest(e);
 }
		void FireTestStepFinishedEvent(TestStepFinishedEventArgs e)
		{
			if (TestStepFinished != null) {
				TestStepFinished(this, e);
			}
		}
        public void If_any_tests_have_failed_an_event_should_be_raised()
        {
            var progressMonitor = MockProgressMonitor.Instance;
            optionsController.Stub(oc => oc.TestRunnerExtensions).Return(new BindingList<string>(new List<string>()));
            StubTestRunnerFactory();
            testController.Explore(progressMonitor, new List<string>());
            var testStepRun = new TestStepRun(new TestStepData("id", "name", "fullName", "testId"))
            {
                Result = new TestResult(TestOutcome.Failed)
            };
            var report = new Report();
            var testData = new TestData("id", "name", "fullName");
            var testStepFinishedEventArgs = new TestStepFinishedEventArgs(report, testData, testStepRun);

            testRunnerEvents.Raise(tre => tre.TestStepFinished += null, testRunner, testStepFinishedEventArgs);

            eventAggregator.AssertWasCalled(ea => ea.Send(Arg.Is(testController), Arg<TestsFailed>.Is.Anything));
        }
        public void TestStepFinished_should_bubble_up_from_test_runner()
        {
            var progressMonitor = MockProgressMonitor.Instance;
            var testRunnerExtensions = new BindingList<string>(new List<string>());
            optionsController.Stub(oc => oc.TestRunnerExtensions).Return(testRunnerExtensions);
            StubTestRunnerFactory();
            testController.Explore(progressMonitor, new List<string>());
            var testData = new TestData("id", "name", "fullName");
            var testStepData = new TestStepData("id", "name", "fullName", "testId")
            {
                IsTestCase = true
            };
            var testStepRun = new TestStepRun(testStepData);
            var testStepFinishedEventArgs = new TestStepFinishedEventArgs(new Report(), 
                testData, testStepRun);

            testRunnerEvents.Raise(tre => tre.TestStepFinished += null, testRunner, 
                testStepFinishedEventArgs);

            eventAggregator.AssertWasCalled(ea => ea.Send(Arg.Is(testController), Arg<TestStepFinished>.Matches(tsf => 
                                                                                              tsf.TestData == testData && tsf.TestStepRun == testStepRun)));
        }
 /// <summary>
 /// Dispatches the <see cref="TestStepFinished" /> event.
 /// </summary>
 /// <param name="e">The event arguments.</param>
 public void NotifyTestStepFinished(TestStepFinishedEventArgs e)
 {
     EventHandlerPolicy.SafeInvoke(TestStepFinished, this, e);
 }
示例#10
0
 private void TestStepFinished(object sender, TestStepFinishedEventArgs e)
 {
     TestMonitor testMonitor = GetTestMonitor(e.Test.Id);
     if (testMonitor != null)
         testMonitor.TestStepFinished(e);
 }
示例#11
0
 protected override void LogNonTestCaseProblem(TestStepFinishedEventArgs e)
 {
     LogTest(e);
 }
示例#12
0
 protected override void LogTestCaseFinished(TestStepFinishedEventArgs e)
 {
     LogTest(e);
 }
        private void LogTestCaseFinished(TestStepFinishedEventArgs e)
        {
            var testCase = CreateTestCase(e.Test);

              var testResult = CreateTest(e.Test, e.TestStepRun, testCase);

              _executionRecorder.RecordEnd(testCase, testResult.Outcome);
        }
		void CreateGallioTestStepEventArgs(string testName)
		{
			testStepEventArgs = factory.Create(testName);
		}
示例#15
0
        private void LogTest(TestStepFinishedEventArgs e)
        {
            // A TestResult with State == TestState.Passed won't be displayed in the
            // output window (TD.NET just diplays "[TestName] passed" in the status bar.
            // Since that can be harder to notice, and also is lost when the following
            // test finishes, we print a message in the output window so the user can 
            // progressively see if the tests are passing or failing.
            if (e.TestStepRun.Result.Outcome.Status == TestStatus.Passed)
            {
                testListener.WriteLine(String.Format(Resources.TDNetLogMonitor_TestCasePassed,
                    e.TestStepRun.Step.FullName), FacadeCategory.Info);
            }

            // Inform TD.NET what happened 
            FacadeTestResult result = new FacadeTestResult();
            result.Name = e.TestStepRun.Step.FullName;
            result.TimeSpan = e.TestStepRun.Result.Duration;
            // result.TestRunner = "Gallio"; // note: can crash in older versions of TD.Net with MissingFieldException

            // It's important to set the stack trace here so the user can double-click in the
            // output window to go the faulting line
            StructuredStream failureStream = e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Failures);
            if (failureStream != null)
                result.StackTrace = failureStream.ToString();

            StructuredStream warningStream = e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Warnings);
            if (warningStream != null)
                result.Message = warningStream.ToString();

            // TD.NET will automatically count the number of passed, ignored and failed tests
            // provided we call the TestFinished method with the right State
            result.State = GetTestState(e.TestStepRun.Result.Outcome.Status);

            testListener.TestFinished(result);
        }
示例#16
0
        private void LogTest(TestStepFinishedEventArgs e)
        {
            TestOutcome outcome = e.TestStepRun.Result.Outcome;
            LogSeverity severity = GetLogSeverityForOutcome(outcome);
            string warnings = FormatStream(e.TestStepRun, MarkupStreamNames.Warnings);
            string failures = FormatStream(e.TestStepRun, MarkupStreamNames.Failures);

            var messageBuilder = new StringBuilder();
            messageBuilder.AppendFormat("[{0}] {1} {2}", outcome.DisplayName, e.GetStepKind(), e.TestStepRun.Step.FullName);

            if (warnings.Length != 0)
            {
                messageBuilder.AppendLine();
                messageBuilder.Append(warnings);
                messageBuilder.AppendLine();
            }

            if (failures.Length != 0)
            {
                messageBuilder.AppendLine();
                messageBuilder.Append(failures);
                messageBuilder.AppendLine();
            }

            Logger.Log(severity, messageBuilder.ToString());
        }
示例#17
0
        private void LogTest(TestStepFinishedEventArgs e)
        {
            CodeLocation codeLocation = e.TestStepRun.Step.CodeLocation;
            TestOutcome outcome = e.TestStepRun.Result.Outcome;
            string description = String.Format("[{0}] {1} {2}", outcome.DisplayName, e.GetStepKind(), e.TestStepRun.Step.FullName);

            // Note: We exclude code location column information since it is not very useful in the build output.
            switch (outcome.Status)
            {
                case TestStatus.Passed:
                    taskLoggingHelper.LogMessage(MessageImportance.Normal, description);
                    break;

                case TestStatus.Failed:
                    taskLoggingHelper.LogError(null, null, null, codeLocation.Path, codeLocation.Line, codeLocation.Column, 0, 0, description);
                    break;

                case TestStatus.Skipped:
                case TestStatus.Inconclusive:
                    taskLoggingHelper.LogWarning(null, null, null, codeLocation.Path, codeLocation.Line, codeLocation.Column, 0, 0, description);
                    break;
            }
        }
 /// <summary>
 /// Dispatches the <see cref="TestStepFinished" /> event.
 /// </summary>
 /// <param name="e">The event arguments.</param>
 public void NotifyTestStepFinished(TestStepFinishedEventArgs e)
 {
     EventHandlerPolicy.SafeInvoke(TestStepFinished, this, e);
 }