Udostępnij za pośrednictwem


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)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple := False)> _
Public NotInheritable Class HostTypeAttribute _
    Inherits Attribute
'Usage
Dim instance As HostTypeAttribute
[AttributeUsageAttribute(AttributeTargets.Method, AllowMultiple = false)]
public sealed class HostTypeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Method, AllowMultiple = false)]
public ref class HostTypeAttribute sealed : public Attribute
public final class HostTypeAttribute extends Attribute

Remarks

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.

Note

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.

Examples

[TestMethod()]
[HostType("ASP.NET")]
[UrlToTest("https://localhost:1371/webSite12")]
[AspNetDevelopmentServerHost("d:\\MyWebSite", "/MyWebSiteRoot")]
public void ConstructorTest()
{
   object target = TestProject1.Class1Accessor.CreatePrivate();
   Assert.Inconclusive("TODO: Implement code to verify target");
}

Inheritance Hierarchy

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

HostTypeAttribute Members

Microsoft.VisualStudio.TestTools.UnitTesting Namespace