Share via


IHostedTest 인터페이스

IHostedTest 인터페이스를 구현하거나 IHostedTest 인터페이스를 구현하는 클래스로부터 상속하는 테스트 형식은 호스트 어댑터에서 호스팅될 수 있습니다. 사용자 지정 테스트 형식은 일반적으로 TestElement 클래스에서 파생되며 TestElement 클래스는 IHostedTest 인터페이스를 구현합니다. 따라서 호스트 어댑터는 TestElement에서 파생되는 모든 테스트 형식을 호스팅할 수 있습니다.

네임스페이스:  Microsoft.VisualStudio.TestTools.Common
어셈블리:  Microsoft.VisualStudio.QualityTools.Common(Microsoft.VisualStudio.QualityTools.Common.dll)

구문

‘선언
Public Interface IHostedTest
public interface IHostedTest
public interface class IHostedTest
type IHostedTest =  interface end
public interface IHostedTest

IHostedTest 형식에서는 다음과 같은 멤버를 노출합니다.

속성

  이름 설명
Public 속성 HostType IHostedTest.HostType 문자열은 호스트를 식별합니다.테스터는 사용자 지정 테스트의 HostType 특성에 이 문자열을 사용하여 해당 테스트를 실행할 호스트를 지정할 수 있습니다.

위쪽

설명

사용자 지정 테스트 형식이 TestElement에서 파생되지 않은 경우, 다음 중 하나를 수행할 경우 테스트는 호스트 어댑터에서 호스트할 수 있습니다.

  • IHostedTest를 구현하기 위한 테스트 형식 코드.

  • 테스트 형식을 IHostedTest 구현하지 마십시오. 이 경우, 레지스트리에서 호스팅 규칙을 구성하면 테스트 형식을 계속 호스팅할 수 있습니다. 자세한 내용은 Configuring Host Adapters and Test Types을 참조하십시오.

속성 창에는 TestElement 제공하는 두 속성이 있습니다. 그것들은 바로 호스트 형식 및 호스트 데이터입니다. 이러한 속성은 TestElement에서 파생되는 모든 테스트 형식에서 사용할 수 있습니다.

예제

다음 전체 예제 코드에 대해서는 Visual Studio SDK의 테스트 확장성 샘플에 있는 MyTest.cs 파일을 참조하십시오.

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;
}

참고 항목

참조

Microsoft.VisualStudio.TestTools.Common 네임스페이스

기타 리소스

Configuring Host Adapters and Test Types