HostTypeAttribute Class
Specifies the type of host on which the associated unit test will run. This class cannot be inherited.
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)
| Name | Description | |
|---|---|---|
![]() | HostTypeAttribute(String^) | Initializes a new instance of the HostTypeAttribute class. This is instantiated by using an argument that specifies the type of host on which this unit test will run. |
![]() | HostTypeAttribute(String^, String^) | Initializes a new instance of the HostTypeAttribute class. This is instantiated by using an argument that specifies the type of host on which this unit test will run, and custom data for the host adapter. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | (Inherited from Attribute.) |
![]() | GetHashCode() | (Inherited from Attribute.) |
![]() | GetType() | (Inherited from Object.) |
![]() | IsDefaultAttribute() | (Inherited from Attribute.) |
![]() | Match(Object^) | (Inherited from Attribute.) |
![]() | ToString() | (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfo(UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfoCount(UInt32) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | (Inherited from Attribute.) |
The type of host identifies the test run on the host, outside the current environment. When a test is run in a different environment, it might also run in a different process. The following example shows that the test is being run in the ASP.NET Development Server address space. This is designated by the AspNetDevelopmentServerHostAttribute. Visual Studio 2005 includes one host adapter called ASP.NET. This is used for ASP.NET unit tests. Customers can create their own host adapters through Visual Studio Industry Partner (VSIP) program.
Note |
|---|
The Visual Studio software development kit (SDK) contains a sample application named "VSIdeHostAdapter." As an example host adapter, it demonstrates how to create a host adapter that runs tests inside a Visual Studio process. |
The HostTypeAttribute can be specified on a test method. Only a single instance of this attribute can occur on a method.
For more information about how to use attributes, see Extending Metadata Using Attributes.
Legacy Code Example
[TestMethod()] [HostType("ASP.NET")] [UrlToTest("http://localhost:1371/webSite12")] [AspNetDevelopmentServerHost("d:\\MyWebSite", "/MyWebSiteRoot")] public void ConstructorTest() { object target = TestProject1.Class1Accessor.CreatePrivate(); Assert.Inconclusive("TODO: Implement code to verify target"); }
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.




