Export (0) Print
Expand All

TestContext Class

Used to store information that is provided to unit tests.

System.Object
  Microsoft.VisualStudio.TestTools.UnitTesting.TestContext

Namespace:  Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

public abstract class TestContext

The TestContext type exposes the following members.

  NameDescription
Protected methodTestContextInitializes a new instance of an object that derives from the TestContext class.
Top

  NameDescription
Public propertyCurrentTestOutcomeYou can use this property in a TestCleanup method to determine the outcome of a test that has run.
Public propertyDataConnectionWhen overridden in a derived class, gets the current data connection when the test is used for data driven testing.
Public propertyDataRowWhen overridden in a derived class, gets the current data row when test is used for data driven testing.
Public propertyDeploymentDirectoryGets the directory for files deployed for the test run. This property typically contains a subdirectory of TestRunDirectory.
Public propertyFullyQualifiedTestClassNameGets the fully-qualified name of the class that contains the test method that is currently running.
Public propertyPropertiesWhen overridden in a derived class, gets the test properties.
Public propertyRequestedPageGets the requested page.
Public propertyResultsDirectoryGets the top-level directory that contains test results and test result directories for the test run. This is typically a subdirectory of TestRunDirectory.
Public propertyTestDeploymentDirGets the path to the test deployment directory. Deprecated. Use DeploymentDirectory instead.
Public propertyTestDirGets the path to the test directory. Deprecated. Use TestRunDirectory instead.
Public propertyTestLogsDirGets the path to the test log directory. Deprecated. Use TestRunResultsDirectory instead.
Public propertyTestNameGets the test name.
Public propertyTestResultsDirectoryGets the directory for the test result files.
Public propertyTestRunDirectoryGets the top-level directory for the test run that contains deployed files and result files.
Public propertyTestRunResultsDirectoryGets the top-level directory for the test run result files. This property typically contains a subdirectory of ResultsDirectory.
Top

  NameDescription
Public methodAddResultFileWhen overridden in a derived class, adds a file name to the list in TestResult.ResultFileNames.
Public methodBeginTimerWhen overridden in a derived class, begins a timer with the specified name.
Public methodEndTimerWhen overridden in a derived class, ends a timer with the specified name.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWriteLineWhen overridden in a derived class, used to write trace messages while the test is running.
Top

  NameDescription
Public fieldStatic memberAspNetDevelopmentServerPrefixRepresents the prefix for ASP.NET Development Server.
Top

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft