Export (0) Print
Expand All

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
/** @attribute AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple=false) */ 
public final class HostTypeAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple=false) 
public final class HostTypeAttribute extends Attribute

The type of host identifies the test as being run outside the current environment. In other words, the test is run in the address space of 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.

This 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.

Community Additions

ADD
Show:
© 2014 Microsoft