This documentation is archived and is not being maintained.

HostTypeAttribute Class

Used to specify the type of host that this unit test will run in. This class cannot be inherited.

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

[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = false)]
public sealed class HostTypeAttribute : Attribute

The type of host identifies the test as being run 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 the test being run in the ASP.NET Development Server address space. This is designated by the AspNetDevelopmentServerHostAttribute. You do this by using a host adapter. Visual Studio 2005 includes one host adapter called ASP.NET. This is used for ASP.NET unit testing. Customers can create their own host adapters through Visual Studio Industry Partner (VSIP) program.

NoteNote:

The Visual Studio SDK contains a sample application called "VSIdeHostAdapter." As an example host adapter, it demonstrates how to create a host adapter that runs tests inside a Visual Studio process.

The HostTypeAttribute attribute can be specified on a test method. There can be only a single instance of this attribute on a method.

For more information about how to use attributes, see Extending Metadata Using Attributes.

[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");
}

System.Object
  System.Attribute
    Microsoft.VisualStudio.TestTools.UnitTesting.HostTypeAttribute

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: