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.
public class TestExecutionContext : LongLivedMarshalByRefObject
- Inheritance
-
TestExecutionContext
- Derived
- 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
CancellationToken
Gets or sets the CancellationToken for the test case.
public CancellationToken CancellationToken { get; }
Property Value
CurrentContext
Gets and sets the current context.
public static TestExecutionContext CurrentContext { get; }
Property Value
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
CurrentRepeatCount
The number of times the current test has been scheduled for execution. Currently only being executed in a test using the RetryAttribute
public int CurrentRepeatCount { 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
CurrentValueFormatter
The current head of the ValueFormatter chain, copied from MsgUtils.ValueFormatter
public ValueFormatter CurrentValueFormatter { get; }
Property Value
DefaultFloatingPointTolerance
Default tolerance value used for floating point equality when no other tolerance is specified.
public Tolerance DefaultFloatingPointTolerance { get; set; }
Property Value
Dispatcher
The current WorkItemDispatcher. Made public for use by nunitlite.tests
public IWorkItemDispatcher Dispatcher { get; set; }
Property Value
Duration
Gets the elapsed time for running the test in seconds
public double Duration { get; }
Property Value
ExecutionStatus
Gets an enum indicating whether a stop has been requested.
public TestExecutionStatus ExecutionStatus { get; set; }
Property Value
IsSingleThreaded
If true, all tests must run on the same thread. No new thread may be spawned.
public bool IsSingleThreaded { get; set; }
Property Value
OutWriter
Gets a TextWriter that will send output to the current test result.
public TextWriter OutWriter { get; }
Property Value
ParallelScope
The ParallelScope to be used by tests running in this context. For builds with out the parallel feature, it has no effect.
public ParallelScope ParallelScope { get; set; }
Property Value
RandomGenerator
Gets the RandomGenerator specific to this Test
public Randomizer 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
TestWorker
The worker that spawned the context. For builds without the parallel feature, it is null.
public TestWorker? TestWorker { get; }
Property Value
UpstreamActions
Gets a list of ITestActions set by upstream tests
public List<ITestAction> UpstreamActions { get; }
Property Value
UseCancellation
Gets or sets whether the test case should use a CancellationToken.
public bool UseCancellation { get; set; }
Property Value
Methods
AddFormatter(ValueFormatterFactory)
Adds a new ValueFormatterFactory to the chain of formatters
public void AddFormatter(ValueFormatterFactory formatterFactory)
Parameters
formatterFactory
ValueFormatterFactoryThe new factory
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()
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
SendMessage(string, string)
Sends a message from test to listeners. This message is not kind of test output and doesn't go to test result.
public void SendMessage(string destination, string message)
Parameters
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()