Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Team Test API
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)
Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple := False)> _
Public NotInheritable Class HostTypeAttribute _
    Inherits Attribute
Visual Basic (Usage)
Dim instance As HostTypeAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = false)]
public sealed class HostTypeAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Method, AllowMultiple = false)]
public ref class HostTypeAttribute sealed : public Attribute
JScript
public final class HostTypeAttribute extends 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.

ms245480.alert_note(en-us,VS.90).gifNote:

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.

C#
[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.
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker