TestContext Class
Used to store information that is provided to unit tests.
Inheritance Hierarchy
Object
Microsoft.VisualStudio.TestTools.UnitTesting.TestContext
Namespace: Microsoft.VisualStudio.TestTools.UnitTesting
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)
Syntax
'Declaration
Public MustInherit Class TestContext
public abstract class TestContext
public ref class TestContext abstract
[<AbstractClass>]
type TestContext = class end
public abstract class TestContext
The TestContext type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TestContext | Initializes a new instance of an object that derives from the TestContext class. |
Top
Properties
Name | Description | |
---|---|---|
CurrentTestOutcome | You can use this property in a TestCleanup method to determine the outcome of a test that has run. | |
DataConnection | When overridden in a derived class, gets the current data connection when the test is used for data driven testing. | |
DataRow | When overridden in a derived class, gets the current data row when test is used for data driven testing. | |
DeploymentDirectory | Gets the directory for files deployed for the test run. This property typically contains a subdirectory of TestRunDirectory. | |
FullyQualifiedTestClassName | Gets the fully-qualified name of the class that contains the test method that is currently running. | |
Properties | When overridden in a derived class, gets the test properties. | |
RequestedPage | Gets the requested page. | |
ResultsDirectory | Gets the top-level directory that contains test results and test result directories for the test run. This is typically a subdirectory of TestRunDirectory. | |
TestDeploymentDir | Gets the path to the test deployment directory. Deprecated. Use DeploymentDirectory instead. | |
TestDir | Gets the path to the test directory. Deprecated. Use TestRunDirectory instead. | |
TestLogsDir | Gets the path to the test log directory. Deprecated. Use TestRunResultsDirectory instead. | |
TestName | Gets the test name. | |
TestResultsDirectory | Gets the directory for the test result files. | |
TestRunDirectory | Gets the top-level directory for the test run that contains deployed files and result files. | |
TestRunResultsDirectory | Gets the top-level directory for the test run result files. This property typically contains a subdirectory of ResultsDirectory. |
Top
Methods
Name | Description | |
---|---|---|
AddResultFile | When overridden in a derived class, adds a file name to the list in TestResult.ResultFileNames. | |
BeginTimer | When overridden in a derived class, begins a timer with the specified name. | |
EndTimer | When overridden in a derived class, ends a timer with the specified name. | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
WriteLine | When overridden in a derived class, used to write trace messages while the test is running. |
Top
Fields
Name | Description | |
---|---|---|
AspNetDevelopmentServerPrefix | Represents the prefix for ASP.NET Development Server. |
Top
Remarks
This class cannot be instantiated. Do not create a class that inherits from this class. For more information, see Using the TestContext Class.
For an example of how you can use TestContext to create a data-driven unit test, see How To: Create a Data-Driven Unit Test.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
Microsoft.VisualStudio.TestTools.UnitTesting Namespace