Exemplo n.º 1
0
        public void BeginTest(string testName)
        {
            if (LoggingState == LoggingState.IsConnected)
            {
                BeginVariation("Two variations created.");
                LogMessage("Log consumer has attempted to call Begin Test Twice.");
                LogResult(Result.Fail);
                EndVariation("Two variations created.");
            }
            else if (LoggingState == LoggingState.HasVariation)
            {
                LogMessage("Log consumer has attempted to call Begin Test Twice.");
                LogResult(Result.Fail);
                EndVariation(currentVariationName);
            }
            else
            {
                hasConnection = true;
                // If BeginTest specifies a different test name we will record
                // a warning in the execution event log. We could be even more
                // aggressive and create a dead test for the registered test.
                if (!String.Equals(this.currentTestName, testName))
                {
                    // If we're in debugging mode and the test name matches the first
                    // registered test, then what happened is the driver was rerun.
                    // In this case we can recover by reseting the loggers.
                    if (isDebugging && String.Equals(testName, registeredTests[0].TestInfo.Name))
                    {
                        Reset();
                        Loggers.Reset();
                    }
                    else
                    {
                        ExecutionEventLog.RecordStatus(string.Format(CultureInfo.InvariantCulture, "BeginTest specified '{0}' but test name registered was '{1}'.", testName, this.currentTestName));
                        throw new Exception("This is super serious now that we have execution groups, we cannot recover safely");
                    }
                }
                Loggers.BeginTest(testName);

                hasReceivedBeginTest = true;
            }
        }