Ejemplo n.º 1
0
        public void RecordState()
        {
            TestState state;

            switch (TestContext.CurrentTestOutcome)
            {
            case UnitTestOutcome.Error:
            case UnitTestOutcome.Failed:
            case UnitTestOutcome.Timeout:
                state = TestState.Failed;
                break;

            case UnitTestOutcome.Passed:
                state = TestState.Passed;
                break;

            case UnitTestOutcome.Inconclusive:
                state = TestState.Ignored;
                break;

            default:
                state = TestState.Unknown;
                break;
            }

            _testStateManager.SetThenState(TestContext.TestName, state, Message ?? string.Empty);

            if (_testStateManager.Thens.All(x => x.Value.State != TestState.Unknown))
            {
                _testStateManager.Cleanup();
            }
        }
Ejemplo n.º 2
0
        public void RecordState()
        {
            var       context = TestContext.CurrentContext;
            TestState state;

            TestStatus status;

            try
            {
                status = context.Result.Status;
            }
            catch (Exception)
            {
                status = TestStatus.Inconclusive;
            }

            switch (status)
            {
            case TestStatus.Failed:
                state = TestState.Failed;
                break;

            case TestStatus.Passed:
                state = TestState.Passed;
                break;

            case TestStatus.Skipped:
                state = TestState.Ignored;
                break;

            default:
                state = TestState.Unknown;
                break;
            }

            var message = GetTestExecutionMessage();

            try
            {
                _testStateManager.SetThenState(context.Test.Name, state, message == null ? string.Empty : message.ToString());
            }
            catch (Exception)
            {
            }
        }