Programming‎ > ‎MSTEST‎ > ‎

testmembers

VS UNIT TEST

http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting(VS.80).aspx

Test Classes

Configuration related

 ClassDescription
Public classTestConfiguration Provides access to a TestConfigurationSection that represents the microsoft.visualstudio.testtools section in an app.config file.
Public class TestConfigurationSection Provides access to data source configuration data.
Public class TestsContext Used to store information that is provided to unit tests.

Objects and Types

 ClassDescription
Public classPrivate ObjectAllows test code to call methods and properties on the code under test that would be inaccessible because they are not public.  Automatically generated by the framework.
Public classPrivateTypeRepresents the type of a private class that gives access to private static implementations.

Assert classes for test verification

 ClassDescription
Public classAssertVerifies conditions in unit tests using true/false propositions.
Public class CollectionAssertVerifies true/false propositions associated with collections in unit tests.
Public classStringAssertVerifies true/false propositions associated with strings in unit tests.

Exception classes

 ClassDescription
Public classAssertInconclusiveExceptionUsed to indicate that a test is not yet implemented.
Public classAssertFailedExceptionUsed to indicate failure for a test.
Public classUnitTestAssertExceptionThis is the base class for unit test exceptions.
Public classInternalTestFailureExceptionThe exception that is thrown to indicate an internal failure for a test.


Test Class and Methods

  ClassDescription
Public classTestClassAttributeUsed to identify classes that contain test methods. This class cannot be inherited.
Public classTestMethodAttributeUsed to identify test methods. This class cannot be inherited.

Attribute classes used  like [AssemblyInitialize()] etc in the attribute for a method .  

Initialization Attributes

The order of the methods in the unit test will be run is specified by the attributes:
  1. Methods marked with the AssemblyInitializeAttribute.
  2. Methods marked with the ClassInitializeAttribute.  (used for initialization only once to the entire test)
  3. Methods marked with the TestInitializeAttribute.  (run once for every user iteration.)
  4. Methods marked with the TestMethodAttribute.

  ClassDescription
Public classAssemblyInitializeAttributeIdentifies a method that contains code to be used before all tests in the assembly have run and to allocate resources obtained by the assembly. This class cannot be inherited.
Public classClassInitializeAttributeIdentifies a method that contains code that must be used before any of the tests in the test class have run and to allocate resources to be used by the test class. This class cannot be inherited.
Public classTestInitializeAttributeIdentifies the method to run before the test to allocate and configure resources needed by all tests in the test class. This class cannot be inherited.

Cleanup Attributes

  ClassDescription
Public classAssemblyCleanupAttributeIdentifies a method that contains code to be used after all tests in the assembly have run and to free resources obtained by the assembly. This class cannot be inherited.
Public classClassCleanupAttributeIdentifies a method that contains code to be used after all the tests in the test class have run and to free resources obtained by the test class. This class cannot be inherited.
Public classTestCleanupAttributeIdentifies a method that contains code that must be used after the test has run and to free resources obtained by all the tests in the test class. This class cannot be inherited.

Modifier Attributes for TestMethod

  ClassDescription
Public classExpectedExceptionAttributeIndicates that an exception is expected during test method execution. This class cannot be inherited.    E.g. [ExpectedException(typeof(System.DividedByZeroException)]
Public classIgnoreAttributeIndicates that a specific test should not be run. This class cannot be inherited.  [Ignore()] (the test will be greyed out).
Public classTimeoutAttributeUsed to specify the time-out period of a unit test in milliseconds.
Public classDescriptionAttributeUsed to specify the description of the test. This class cannot be inherited.  e.g. [Description("test")]
Public classDataSourceAttributeProvides data source-specific information for data-driven testing. This class cannot be inherited.  Examples are: 

[DataSource("Provider=SQLOLEDB.1;Data Source=MySource;Integrated] Security=SSPI;Initial Catalog=MyCatalog;Persist Security Info=False", "MyTable")]

[DataSource("dataSourceNameFromConfigFile")]

Public classTestPropertyAttributeEstablishes a test specific property on a method. This class cannot be inherited.  e.g. [TestProperty("Name", "value"]

Other Attributes

  ClassDescription
Public classCssIterationAttributeRepresents the project iteration to which this test corresponds. This class cannot be inherited.
Public classCssProjectStructureAttributeRepresents the node in the team project hierarchy to which this test corresponds.
Public classDeploymentItemAttributeUsed to specify deployment items such as files or directories for per-test deployment. This class cannot be inherited.   Used for create Test Deployment.
Public classHostTypeAttributeUsed to specify the type of host that this unit test will run in. This class cannot be inherited.   Currently only one type type, i.e. [HostType("ASP.NET")]
Public classOwnerAttributeUsed to specify the person responsible for maintaining, running, and/or debugging the test. This class cannot be inherited.
Public classPriorityAttributeUsed to specify the priority of a unit test. This class cannot be inherited.
Public classWorkItemAttributeUsed to specify a work item associated with a test.

Assert Static Public Members

 Name Description
Public methodStaticAreEqualOverloaded. Verifies that specified values are equal.  
Public methodStaticAreNotEqualOverloaded. Verifies that specified values are not equal.  
Public methodStaticAreNotSameOverloaded. Verifies that specified object variables refer to different objects.  
Public methodStaticAreSameOverloaded. Verifies that specified object variables refer to the same object.  
Public methodStaticFailOverloaded. Fails an assertion without checking any conditions.  
Public methodStaticInconclusiveOverloaded. Indicates that an assertion cannot be proven true or false. Also used to indicate an assertion that has not yet been implemented.  
Public methodStaticIsFalseOverloaded. Verifies that a specified condition is false.  
Public methodStaticIsInstanceOfTypeOverloaded. Verifies that a specified object is an instance of a specified type.  
Public methodStaticIsNotInstanceOfTypeOverloaded. Verifies that a specified object is not an instance of a specified type.  
Public methodStaticIsNotNullOverloaded. Verifies that a specified object is not a null reference (Nothing in Visual Basic).  
Public methodStaticIsNullOverloaded. Verifies that a specified object is null.  
Public methodStaticIsTrueOverloaded. Verifies that a specified condition is true.  
Public methodStaticReferenceEquals (Inherited from Object.)

Collection Assert Static Public Members

 Name Description
Public methodStaticAllItemsAreInstancesOfTypeOverloaded. Verifies that all elements in a specified collection are instances of a specified type.  
Public methodStaticAllItemsAreNotNullOverloaded. Verifies that all items in a specified collection are not a null reference (Nothing in Visual Basic).  
Public methodStaticAllItemsAreUniqueOverloaded. Verifies that all items in a specified collection are unique.  
Public methodStaticAreEqualOverloaded. Verifies that specified collections are equal. Two collections are equal if they have the same elements in the same order and quantity. Elements are equal if their values are equal, not if they refer to the same object.  
Public methodStaticAreEquivalentOverloaded. Verifies that the specified collections are equivalent. Two collections are equivalent if they have the same elements in the same quantity, but in any order. Elements are equal if their values are equal, not if they refer to the same object.  
Public methodStaticAreNotEqualOverloaded. Verifies that specified collections are not equal.  
Public methodStaticAreNotEquivalentOverloaded. Verifies that the specified collections are not equivalent.  
Public methodStaticContainsOverloaded. Verifies that a specified collection contains a specified element.  
Public methodStaticDoesNotContainOverloaded. Verifies that a specified collection does not contain a specified element.  
Public methodStaticIsNotSubsetOfOverloaded. Verifies that one collection is not a subset of another collection.  
Public methodStaticIsSubsetOfOverloaded. Verifies that one collection is a subset of another collection.  
Public methodStaticReferenceEquals (Inherited from Object.)

StringAssert Static Public Members

 Name Description
Public methodStaticContainsOverloaded. Verifies that a specified string contains a specified substring.  
Public methodStaticDoesNotMatchOverloaded. Verifies that a specified string does not match a regular expression.  
Public methodStaticEndsWithOverloaded. Verifies that a specified string ends with a specified substring.  
Public methodStaticMatchesOverloaded. Verifies that a specified string matches a regular expression.  
Public methodStaticReferenceEquals (Inherited from Object.)
Public methodStaticStartsWithOverloaded. Verifies that a specified string begins with a specified substring. Â