Table of Contents

Class TestExecutionContext

Namespace
NUnit.Framework.Internal
Assembly
nunit.framework.dll

Helper class used to save and restore certain static or singleton settings in the environment that affect tests or which might be changed by the user tests.

An internal class is used to hold settings and a stack of these objects is pushed and popped as Save and Restore are called.

public class TestExecutionContext : MarshalByRefObject, ILogicalThreadAffinative
Inheritance
TestExecutionContext
Implements
ILogicalThreadAffinative
Inherited Members

Constructors

TestExecutionContext()

Initializes a new instance of the TestExecutionContext class.

public TestExecutionContext()

TestExecutionContext(TestExecutionContext)

Initializes a new instance of the TestExecutionContext class.

public TestExecutionContext(TestExecutionContext other)

Parameters

other TestExecutionContext

An existing instance of TestExecutionContext.

Properties

CurrentContext

Gets the current context.

public static TestExecutionContext CurrentContext { get; }

Property Value

TestExecutionContext

The current context.

CurrentCulture

Saves or restores the CurrentCulture

public CultureInfo CurrentCulture { get; set; }

Property Value

CultureInfo

CurrentPrincipal

Gets or sets the current IPrincipal for the Thread.

public IPrincipal CurrentPrincipal { get; set; }

Property Value

IPrincipal

CurrentResult

Gets or sets the current test result

public TestResult CurrentResult { get; set; }

Property Value

TestResult

CurrentTest

Gets or sets the current test

public Test CurrentTest { get; set; }

Property Value

Test

CurrentUICulture

Saves or restores the CurrentUICulture

public CultureInfo CurrentUICulture { get; set; }

Property Value

CultureInfo

ExecutionStatus

Gets an enum indicating whether a stop has been requested.

public TestExecutionStatus ExecutionStatus { get; set; }

Property Value

TestExecutionStatus

ParallelScope

The ParallelScope to be used by tests running in this context

public ParallelScope ParallelScope { get; set; }

Property Value

ParallelScope

RandomGenerator

Gets the RandomGenerator specific to this Test

public RandomGenerator RandomGenerator { get; }

Property Value

RandomGenerator

StartTicks

The time the current test started in Ticks

public long StartTicks { get; set; }

Property Value

long

StartTime

The time the current test started execution

public DateTime StartTime { get; set; }

Property Value

DateTime

StopOnError

Get or set indicator that run should stop on the first error

public bool StopOnError { get; set; }

Property Value

bool

TestCaseTimeout

Gets or sets the test case timeout value

public int TestCaseTimeout { get; set; }

Property Value

int

TestObject

The current test object - that is the user fixture object on which tests are being executed.

public object TestObject { get; set; }

Property Value

object

UpstreamActions

Gets a list of ITestActions set by upstream tests

public List<ITestAction> UpstreamActions { get; }

Property Value

List<ITestAction>

WorkDirectory

Get or set the working directory

public string WorkDirectory { get; set; }

Property Value

string

Methods

ClearCurrentContext()

Clear the current context. This is provided to prevent "leakage" of the CallContext containing the current context back to any runners.

public static void ClearCurrentContext()

EstablishExecutionEnvironment()

Set up the execution environment to match a context. Note that we may be running on the same thread where the context was initially created or on a different thread.

public void EstablishExecutionEnvironment()

GetTestExecutionContext()

Get the current context or return null if none is found.

public static TestExecutionContext GetTestExecutionContext()

Returns

TestExecutionContext

IncrementAssertCount()

Increments the assert count by one.

public void IncrementAssertCount()

IncrementAssertCount(int)

Increments the assert count by a specified amount.

public void IncrementAssertCount(int count)

Parameters

count int

InitializeLifetimeService()

Obtain lifetime service object

public override object InitializeLifetimeService()

Returns

object

UpdateContextFromEnvironment()

Record any changes in the environment made by the test code in the execution context so it will be passed on to lower level tests.

public void UpdateContextFromEnvironment()