Condividi tramite


Interfaccia IHostedTest

Un tipo di test che implementa l'interfaccia IHostedTest o che eredita da una classe che implementa l'interfaccia IHostedTest può essere ospitato da un adattatore host. I tipi di test personalizzati derivano generalmente dalla classe TestElement, la quale implementa l'interfaccia IHostedTest. Di conseguenza, qualsiasi tipo di test derivante da TestElement può essere ospitato da un adattatore host.

Spazio dei nomi:  Microsoft.VisualStudio.TestTools.Common
Assembly:  Microsoft.VisualStudio.QualityTools.Common (in Microsoft.VisualStudio.QualityTools.Common.dll)

Sintassi

'Dichiarazione
Public Interface IHostedTest
public interface IHostedTest
public interface class IHostedTest
type IHostedTest =  interface end
public interface IHostedTest

Il tipo IHostedTest espone i seguenti membri.

Proprietà

  Nome Descrizione
Proprietà pubblica HostType La stringa IHostedTest.HostType identifica un host.I tester possono utilizzare questa stringa nell'attributo HostType in un test personalizzato per specificare un host in cui eseguire quel test.

In alto

Note

Se il tipo di test personalizzato non deriva da TestElement, i test possono essere ospitati da un adattatore host nei seguenti casi:

  • Eseguire la codifica del tipo di test per implementare IHostedTest.

  • Non consentire al tipo di test di implementare IHostedTest. In questo caso, il tipo di test può ancora essere ospitato se si configurano le regole di hosting nel Registro di sistema. Per ulteriori informazioni, vedere Configuring Host Adapters and Test Types.

La finestra della proprietà dispone di due proprietà che TestElement fornisce: tipo host e dati host. Queste proprietà sono disponibili per qualsiasi tipo di test che deriva da TestElement.

Esempi

Per il codice completo dell'esempio seguente, vedere il file MyTest.cs nell'esempio di estensibilità dei test in Visual Studio SDK.

using Microsoft.VisualStudio.TestTools.Common;
using Microsoft.VisualStudio.TestTools.Vsip;

class MyTest : TestElement 
{
    // TestElement - specific members.
    // ...

    // Copy constructor: copy m_hostType.
    public MyTest(MyTest copy)
        : base(copy)
    {
        // TestElement - specific data.
        // …

        m_hostType = copy.m_hostType;
    }

    // ITestElement.Clone is required by test case management.
    // Call copy constructor which copies m_hostType, 
    // so that cloned test has the same m_hostType as original test.
    public override object Clone()
    {
        return new MyTest(this);
    }

    // Persisted host type associated with the test.
    [PersistenceElementName("HostType")]
    private string m_hostType;
}

Vedere anche

Riferimenti

Spazio dei nomi Microsoft.VisualStudio.TestTools.Common

Altre risorse

Configuring Host Adapters and Test Types