Esempio n. 1
0
        public void OnTestFinished(object testClass, string testName, PtfTestOutcome testOutcome, AssertExceptionHandler exceptionHandler)
        {
            testProperties[TestPropertyNames.CurrentTestCaseName] = testName;
            testProperties[TestPropertyNames.CurrentTestOutcome]  = testOutcome;

            EventHandler <TestStartFinishEventArgs> handler = eventTable["TestFinished"];

            try
            {
                if (handler != null)
                {
                    //may throw exception and make test finish
                    handler(this, new TestStartFinishEventArgs(testName, testOutcome));
                }

                this.InvokeActions(typeof(ProtocolTestCleanupAttribute), testClass);
                UpdateTestResultsStatistics(testOutcome);
            }
            catch (Exception e)
            {
                UpdateTestResultsStatistics(exceptionHandler(e));
                throw;
            }
            finally
            {
                this.Log.Add(LoggingHelper.PtfTestOutcomeToLogEntryKind(testOutcome), testName);
                this.Log.Add(LogEntryKind.ExitMethod, testName);

                this.WaitForProcessMessage();

                testProperties[TestPropertyNames.CurrentTestCaseName] = null;
                testProperties[TestPropertyNames.CurrentTestOutcome]  = PtfTestOutcome.Unknown;
            }
        }
Esempio n. 2
0
        private static TestStatus PtfTestOutcomeToTestStatus(PtfTestOutcome testOutcome)
        {
            //keep the previous test status if not changing
            TestStatus result = TestStatus.Framework;

            switch (testOutcome)
            {
            case PtfTestOutcome.Passed:
            case PtfTestOutcome.Aborted:
            case PtfTestOutcome.Error:
            case PtfTestOutcome.Failed:
            case PtfTestOutcome.Timeout:
            case PtfTestOutcome.Inconclusive:
                result = TestStatus.Stop;
                break;

            case PtfTestOutcome.InProgress:
                result = TestStatus.Running;
                break;

            case PtfTestOutcome.Unknown:
                result = TestStatus.Framework;
                break;

            default:
                break;
            }

            return(result);
        }
        /// <summary>
        /// Map a PtfTestOutcome value to its corresponding LogEntryKind value.
        /// </summary>
        /// <param name="unitTestOutcome">Unit test outcome</param>
        /// <returns>The log entry kind</returns>
        public static LogEntryKind PtfTestOutcomeToLogEntryKind(PtfTestOutcome unitTestOutcome)
        {
            LogEntryKind logEntryKind = LogEntryKind.TestUnknown;

            switch(unitTestOutcome)
            {
                case PtfTestOutcome.Failed:
                    logEntryKind = LogEntryKind.TestFailed;
                    break;
                case PtfTestOutcome.Inconclusive:
                    logEntryKind = LogEntryKind.TestInconclusive;
                    break;
                case PtfTestOutcome.Passed:
                    logEntryKind = LogEntryKind.TestPassed;
                    break;
                case PtfTestOutcome.InProgress:
                    logEntryKind = LogEntryKind.TestInProgress;
                    break;
                case PtfTestOutcome.Error:
                    logEntryKind = LogEntryKind.TestError;
                    break;
                case PtfTestOutcome.Timeout:
                    logEntryKind = LogEntryKind.TestTimeout;
                    break;
                case PtfTestOutcome.Aborted:
                    logEntryKind = LogEntryKind.TestAborted;
                    break;
                default:
                    logEntryKind = LogEntryKind.TestUnknown;
                    break;
            }

            return logEntryKind;
        }
        private static void InitializeTestSite(
            IConfigurationData config,
            string configPath,
            string testSuiteName,
            PtfTestOutcome currentTestOutCome,
            string testAssemblyName)
        {
            if (null == config)
            {
                throw new ArgumentException("config cannot be null.");
            }

            if (testSites == null)
            {
                testSites = new Dictionary <string, DefaultTestSite>();
            }

            if (!testSites.ContainsKey(testSuiteName))
            {
                DefaultTestSite testSite = new DefaultTestSite(config, configPath, testSuiteName, testAssemblyName);

                testSites.Add(testSuiteName, testSite);
            }
            else
            {
                testSites[testSuiteName].DisposeAdapters();
            }

            testSites[testSuiteName].TestProperties[TestPropertyNames.CurrentTestCaseName] = null;
            testSites[testSuiteName].TestProperties[TestPropertyNames.CurrentTestOutcome]  = currentTestOutCome;
        }
Esempio n. 5
0
 private void UpdateTestResultsStatistics(PtfTestOutcome testOutcome)
 {
     if (testResultsStatistics.ContainsKey(testOutcome))
     {
         testResultsStatistics[testOutcome]++;
     }
     else
     {
         testResultsStatistics.Add(testOutcome, 1);
     }
 }
Esempio n. 6
0
        private static TestResult PtfTestOutcomeToTestResult(PtfTestOutcome testOutcome)
        {
            //keep the previous test result if not changing
            TestResult result = TestResult.Unknown;

            switch (testOutcome)
            {
            case PtfTestOutcome.Passed:
                result = TestResult.Passed;
                break;

            case PtfTestOutcome.Aborted:
                result = TestResult.Aborted;
                break;

            case PtfTestOutcome.Error:
                result = TestResult.Error;
                break;

            case PtfTestOutcome.Failed:
                result = TestResult.Failed;
                break;

            case PtfTestOutcome.Timeout:
                result = TestResult.Timeout;
                break;

            case PtfTestOutcome.Inconclusive:
                result = TestResult.Inconclusive;
                break;

            case PtfTestOutcome.Unknown:
                result = TestResult.Unknown;
                break;

            case PtfTestOutcome.InProgress:
                result = TestResult.InProgress;
                break;

            default:
                break;
            }

            return(result);
        }
        /// <summary>
        /// Map a PtfTestOutcome value to its corresponding LogEntryKind value.
        /// </summary>
        /// <param name="unitTestOutcome">Unit test outcome</param>
        /// <returns>The log entry kind</returns>
        public static LogEntryKind PtfTestOutcomeToLogEntryKind(PtfTestOutcome unitTestOutcome)
        {
            LogEntryKind logEntryKind = LogEntryKind.TestUnknown;

            switch (unitTestOutcome)
            {
            case PtfTestOutcome.Failed:
                logEntryKind = LogEntryKind.TestFailed;
                break;

            case PtfTestOutcome.Inconclusive:
                logEntryKind = LogEntryKind.TestInconclusive;
                break;

            case PtfTestOutcome.Passed:
                logEntryKind = LogEntryKind.TestPassed;
                break;

            case PtfTestOutcome.InProgress:
                logEntryKind = LogEntryKind.TestInProgress;
                break;

            case PtfTestOutcome.Error:
                logEntryKind = LogEntryKind.TestError;
                break;

            case PtfTestOutcome.Timeout:
                logEntryKind = LogEntryKind.TestTimeout;
                break;

            case PtfTestOutcome.Aborted:
                logEntryKind = LogEntryKind.TestAborted;
                break;

            default:
                logEntryKind = LogEntryKind.TestUnknown;
                break;
            }

            return(logEntryKind);
        }
Esempio n. 8
0
        private static PtfTestOutcome UnitTestOutcomeToPtfTestOutcome(UnitTestOutcome uto)
        {
            PtfTestOutcome pto = PtfTestOutcome.Unknown;

            switch (uto)
            {
            case UnitTestOutcome.Failed:
                pto = PtfTestOutcome.Failed;
                break;

            case UnitTestOutcome.Inconclusive:
                pto = PtfTestOutcome.Inconclusive;
                break;

            case UnitTestOutcome.Passed:
                pto = PtfTestOutcome.Passed;
                break;

            case UnitTestOutcome.InProgress:
                pto = PtfTestOutcome.InProgress;
                break;

            case UnitTestOutcome.Error:
                pto = PtfTestOutcome.Error;
                break;

            case UnitTestOutcome.Timeout:
                pto = PtfTestOutcome.Timeout;
                break;

            case UnitTestOutcome.Aborted:
                pto = PtfTestOutcome.Aborted;
                break;

            default:
                pto = PtfTestOutcome.Unknown;
                break;
            }

            return(pto);
        }
Esempio n. 9
0
        public override void PrepareLogInformation(
            LogEntryKind kind,
            string message,
            DateTime timeStamp,
            Dictionary <string, Object> testProperties)
        {
            if (testProperties.ContainsKey(TestPropertyNames.CurrentTestCaseName) &&
                testProperties[TestPropertyNames.CurrentTestCaseName] != null)
            {
                testCaseName = testProperties[TestPropertyNames.CurrentTestCaseName] as string;
            }
            else
            {
                testCaseName = null;
            }

            if (testProperties.ContainsKey(TestPropertyNames.CurrentTestOutcome) &&
                testProperties[TestPropertyNames.CurrentTestOutcome] != null)
            {
                PtfTestOutcome currentTestOutcome =
                    (PtfTestOutcome)testProperties[TestPropertyNames.CurrentTestOutcome];
                UpdateStatus(currentTestOutcome);
            }
        }
 private void UpdateStatus(PtfTestOutcome currentTestOutcome)
 {
     testResult = PtfTestOutcomeToTestResult(currentTestOutcome);
     testStatus = PtfTestOutcomeToTestStatus(currentTestOutcome);
 }
        private static TestStatus PtfTestOutcomeToTestStatus(PtfTestOutcome testOutcome)
        {
            //keep the previous test status if not changing
            TestStatus result = TestStatus.Framework;

            switch (testOutcome)
            {
                case PtfTestOutcome.Passed:
                case PtfTestOutcome.Aborted:
                case PtfTestOutcome.Error:
                case PtfTestOutcome.Failed:
                case PtfTestOutcome.Timeout:
                case PtfTestOutcome.Inconclusive:
                    result = TestStatus.Stop;
                    break;
                case PtfTestOutcome.InProgress:
                    result = TestStatus.Running;
                    break;
                case PtfTestOutcome.Unknown:
                    result = TestStatus.Framework;
                    break;
                default:
                    break;
            }

            return result;
        }
        private static TestResult PtfTestOutcomeToTestResult(PtfTestOutcome testOutcome)
        {
            //keep the previous test result if not changing
            TestResult result = TestResult.Unknown;
            switch (testOutcome)
            {
                case PtfTestOutcome.Passed:
                    result = TestResult.Passed;
                    break;

                case PtfTestOutcome.Aborted:
                    result = TestResult.Aborted;
                    break;

                case PtfTestOutcome.Error:
                    result = TestResult.Error;
                    break;

                case PtfTestOutcome.Failed:
                    result = TestResult.Failed;
                    break;

                case PtfTestOutcome.Timeout:
                    result = TestResult.Timeout;
                    break;

                case PtfTestOutcome.Inconclusive:
                    result = TestResult.Inconclusive;
                    break;

                case PtfTestOutcome.Unknown:
                    result = TestResult.Unknown;
                    break;

                case PtfTestOutcome.InProgress:
                    result = TestResult.InProgress;
                    break;

                default:
                    break;
            }

            return result;
        }
Esempio n. 13
0
 private void UpdateStatus(PtfTestOutcome currentTestOutcome)
 {
     testResult = PtfTestOutcomeToTestResult(currentTestOutcome);
     testStatus = PtfTestOutcomeToTestStatus(currentTestOutcome);
 }
Esempio n. 14
0
 /// <summary>
 /// Constructs a TestStartFinishEventArgs instance which contains the test case name.
 /// </summary>
 /// <param name="testName">The current test case name.</param>
 /// <param name="testOutcome">The current test outcome.</param>
 public TestStartFinishEventArgs(string testName, PtfTestOutcome testOutcome)
 {
     this.testCaseName = testName;
     this.testOutcome  = testOutcome;
 }
Esempio n. 15
0
 /// <summary>
 /// Constructs a TestStartFinishEventArgs instance which contains the test case name.
 /// </summary>
 /// <param name="testName">The current test case name.</param>
 /// <param name="testOutcome">The current test outcome.</param>
 public TestStartFinishEventArgs(string testName, PtfTestOutcome testOutcome)
 {
     this.testCaseName = testName;
     this.testOutcome = testOutcome;
 }
        private static void InitializeTestSite(
            IConfigurationData config,
            string configPath, 
            string testSuiteName,
            PtfTestOutcome currentTestOutCome,
            string testAssemblyName)
        {
            if (null == config)
            {
                throw new ArgumentException("config cannot be null.");
            }

            if (testSites == null)
            {
                testSites = new Dictionary<string, DefaultTestSite>();
            }

            if (!testSites.ContainsKey(testSuiteName))
            {
                DefaultTestSite testSite = new DefaultTestSite(config, configPath, testSuiteName, testAssemblyName);

                testSites.Add(testSuiteName, testSite);
            }
            else
            {
                testSites[testSuiteName].DisposeAdapters();
            }

            testSites[testSuiteName].TestProperties[TestPropertyNames.CurrentTestCaseName] = null;
            testSites[testSuiteName].TestProperties[TestPropertyNames.CurrentTestOutcome] = currentTestOutCome;
        }