Class TestExecutionContext
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
TestExecutionContextAn 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
CurrentPrincipal
Gets or sets the current IPrincipal for the Thread.
public IPrincipal CurrentPrincipal { get; set; }
Property Value
CurrentResult
Gets or sets the current test result
public TestResult CurrentResult { get; set; }
Property Value
CurrentTest
Gets or sets the current test
public Test CurrentTest { get; set; }
Property Value
CurrentUICulture
Saves or restores the CurrentUICulture
public CultureInfo CurrentUICulture { get; set; }
Property Value
ExecutionStatus
Gets an enum indicating whether a stop has been requested.
public TestExecutionStatus ExecutionStatus { get; set; }
Property Value
ParallelScope
The ParallelScope to be used by tests running in this context
public ParallelScope ParallelScope { get; set; }
Property Value
RandomGenerator
Gets the RandomGenerator specific to this Test
public RandomGenerator RandomGenerator { get; }
Property Value
StartTicks
The time the current test started in Ticks
public long StartTicks { get; set; }
Property Value
StartTime
The time the current test started execution
public DateTime StartTime { get; set; }
Property Value
StopOnError
Get or set indicator that run should stop on the first error
public bool StopOnError { get; set; }
Property Value
TestCaseTimeout
Gets or sets the test case timeout value
public int TestCaseTimeout { get; set; }
Property Value
TestObject
The current test object - that is the user fixture object on which tests are being executed.
public object TestObject { get; set; }
Property Value
UpstreamActions
Gets a list of ITestActions set by upstream tests
public List<ITestAction> UpstreamActions { get; }
Property Value
WorkDirectory
Get or set the working directory
public string WorkDirectory { get; set; }
Property Value
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
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
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()