DoOneTimeSetUp() public method

Does the one time set up for a suite command. Broadly defined, this includes: 1. Applying changes specified by attributes to the context 2. Constructing the user fixture instance 3. Calling the one time setup methods themselves
public DoOneTimeSetUp ( TestExecutionContext context ) : void
context TestExecutionContext The execution context to use in running the test.
return void
示例#1
0
        private static TestResult ExecuteSuiteCommand(TestSuiteCommand command, TestExecutionContext context)
        {
            //return command.Execute(context);
            TestSuiteResult suiteResult = context.CurrentResult as TestSuiteResult;

            System.Diagnostics.Debug.Assert(suiteResult != null);

            bool oneTimeSetUpComplete = false;

            try
            {
                // Temporary: this should be done by individual commands
                ApplyTestSettingsToExecutionContext(command.Test, context);

                command.DoOneTimeSetUp(context);
                oneTimeSetUpComplete = true;

                // SetUp may have changed some things
                context.Update();

                suiteResult = RunChildCommands(command, context);
            }
            catch (Exception ex)
            {
                if (ex is NUnitException || ex is System.Reflection.TargetInvocationException)
                {
                    ex = ex.InnerException;
                }


                if (oneTimeSetUpComplete)
                {
                    suiteResult.RecordException(ex);
                }
                else
                {
                    suiteResult.RecordException(ex, FailureSite.SetUp);
                }
            }
            finally
            {
                command.DoOneTimeTearDown(context);
            }

            return(suiteResult);
        }
示例#2
0
        private static TestResult ExecuteSuiteCommand(TestSuiteCommand command, TestExecutionContext context)
        {
            //return command.Execute(context);
            TestSuiteResult suiteResult = context.CurrentResult as TestSuiteResult;
            System.Diagnostics.Debug.Assert(suiteResult != null);

            bool oneTimeSetUpComplete = false;
            try
            {
                // Temporary: this should be done by individual commands
                ApplyTestSettingsToExecutionContext(command.Test, context);

                command.DoOneTimeSetUp(context);
                oneTimeSetUpComplete = true;

                // SetUp may have changed some things
                context.Update();

                suiteResult = RunChildCommands(command, context);
            }
            catch (Exception ex)
            {
                if (ex is NUnitException || ex is System.Reflection.TargetInvocationException)
                    ex = ex.InnerException;


                if (oneTimeSetUpComplete)
                    suiteResult.RecordException(ex);
                else
                    suiteResult.RecordException(ex, FailureSite.SetUp);
            }
            finally
            {
                command.DoOneTimeTearDown(context);
            }

            return suiteResult;
        }
示例#3
0
        private static TestResult ExecuteSuiteCommand(TestSuiteCommand command, TestExecutionContext context)
        {
            TestSuiteResult testSuiteResult = context.CurrentResult as TestSuiteResult;

            Debug.Assert(testSuiteResult != null);
            bool flag = false;

            try
            {
                ApplyTestSettingsToExecutionContext(command.Test, context);
                command.DoOneTimeSetUp(context);
                flag = true;
                context.Update();
                testSuiteResult = RunChildCommands(command, context);
            }
            catch (Exception innerException)
            {
                if (innerException is NUnitException || innerException is TargetInvocationException)
                {
                    innerException = innerException.InnerException;
                }
                if (flag)
                {
                    testSuiteResult.RecordException(innerException);
                }
                else
                {
                    testSuiteResult.RecordException(innerException, FailureSite.SetUp);
                }
            }
            finally
            {
                command.DoOneTimeTearDown(context);
            }
            return(testSuiteResult);
        }