次の方法で共有


[選択]

テスト作成および実行フレームワーク (TAEF) は、指定したメタデータ情報に基づいて特定のテストを選択的に実行または省略するメカニズムを提供します。 次のセクションでは、TE.exeでこの選択メカニズムを使用する方法のさまざまな例について説明します。

コマンド プロンプト ウィンドウから TE.exe を実行できます。

TE <test_binaries> [/select:<selection criteria>]

このセクションでは、 /select:selection criteria オプション TE.exe について説明します。 TE.exeの詳細については、「TE.exe コマンド オプション」を参照してください。

選択条件は、コマンド プロンプトで説明されているすべてのテスト バイナリにグローバルに適用されます。 Examples\CPP.SelectionCriteria1.Example.dllExamples\CPP.SelectionCriteria2.Example.dll の2つのtest_binariesを考えてみましょう。 次の例は、これらのtest_binariesのさまざまなレベルで指定されたプロパティ (メタデータ) を示しています。 これを取得するには、コマンド プロンプト ウィンドウで /listproperties オプションを指定します。

CPP.SelectionCriteria1.Example.dll (Owner="C1", Priority=3)
class11 (Owner="C2")
method111(Priority=1)

method112 (BackwardsCompatibility="Windows 2000")
class12
method121
CPP.SelectionCriteria2.Example.dll (Owner="WEX")
class21 (Owner="C1", Priority=2, BackwardsCompatibility="Windows XP")
method211 (Owner="C2")
class22 (Owner="U3")
method221

つまり、これらの各test_binariesで /listproperties を個別に使用すると、次の情報が得られます。

F:\fsd1.binaries.x86chk\WexTest\C1\TestExecution>te Examples\CPP.SelectionCriteria1.Example.dll /listproperties
Test Authoring and Execution Framework v2.2 Build 6.1.7689.0 (release.091218-1251) for x86

F:\fsd1.binaries.x86chk\WexTest\C1\TestExecution\Examples\CPP.SelectionCriteria1.Example.dll
        Property[Owner] = C1
        Property[Priority] = 3
    WEX::TestExecution::Examples::Class11
            Property[Owner] = C2
        WEX::TestExecution::Examples::Class11::Method111
                Property[Priority] = 1
        WEX::TestExecution::Examples::Class11::Method112
                Property[BackwardsCompatibility] = Windows2000

    WEX::TestExecution::Examples::Class12
        WEX::TestExecution::Examples::Class12::Method121

および

F:\fsd1.binaries.x86chk\WexTest\C1\TestExecution>te Examples\CPP.SelectionCriteria2.Example.dll /listproperties
Test Authoring and Execution Framework v2.2 Build 6.1.7689.0 (release.091218-1251) for x86

F:\fsd1.binaries.x86chk\WexTest\C1\TestExecution\Examples\CPP.SelectionCriteria2.Example.dll
        Property[Owner] = WEX
    WEX::TestExecution::Examples::Class21
            Property[BackwardsCompatibility] = Windows XP
            Property[Owner] = C1
            Property[Priority] = 2
        WEX::TestExecution::Examples::Class21::Method211
                Property[Owner] = C2

    WEX::TestExecution::Examples::Class22
            Property[Owner] = U3
        WEX::TestExecution::Examples::Class22::Method221

この時点で、test_binariesは完全なパスと共に一覧表示され、ネイティブ test_binariesと "<Namespace>.< の場合はクラス名が "<Namespace>::<ClassName>" として表示されることに注意してください。ClassName>" (マネージド test_binariesの場合)。 同様に、ネイティブの test_binaries の場合、テストメソッド名は "<Namespace>::<ClassName>::<TestMethodName>" として一覧表示され、マネージドの test_binaries の場合は "<Namespace>.<ClassName>.<TestMethodName>" として一覧表示されます。

つまり、任意の名前または関数の完全修飾名は、te に保存されます。 これは、任意のメソッドを一意に区別する機能を許可するためです。 たとえば、2 つのクラスのメソッド名が同じである場合、クラス修飾は、目的のメソッドを一意に選択するのに役立ちます。 この場合、選択条件は、指定されたtest_binariesの条件に一致するテストのみを実行するのに役立ちます。

上記の例では、例\Cpp.SelectionCriteria1.Example.dllで、次のいずれかの選択基準で "Method111" を選択できます。

Te.exe Examples\CPP.SelectionCriteria1.Example.dll /select:"@Name='WEX::TestExecution::Examples::Class11::Method111'"
Te.exe Examples\CPP.SelectionCriteria1.Example.dll /select:"@Name='*Class11::Method111'"
Te.exe Examples\CPP.SelectionCriteria1.Example.dll /select:"@Name='*Method111'"

"Priority" が 2 未満でマークされているすべてのテストを実行するには、次のコマンドを実行します。

Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll /select:"@Priority < 2"

この例では、例\CPP.SelectionCriteria1.Example.dll - "class11::method111" のみを実行します。

class11のすべてのテストを実行したい場合は、修飾 "Name" プロパティとワイルドカード照合を使用して、以下のように選択することができます。

Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll
                                                               /select:"@Name='*::class11::*'"

選択条件を使用する場合は、次の点に注意してください。

  • "and"、"not"、および "or" は 予約語 であり、 大文字と小文字は区別されません
  • メタデータ プロパティの名前と値は大文字小文字が区別されません。たとえば、"C2" は "c2" や "C2" と同じと見なされます。 そのため、「property」というメタデータを持つ関数と「Property」というメタデータを持つ関数があり、選択条件が「PROPERTY」を探している場合、これらの両方が一致することになります。
  • 選択クエリ文字列の文字列値は、一重引用符で囲む必要があります。 選択クエリ "?" の文字列値内には、1 つのワイルドカード文字が含まれており、"*" が 0 個以上のワイルドカード文字です。
  • コマンド プロンプトで引用符を使用するときは、 選択クエリをコピーするときにスマート引用符に注意してください。 Outlook の電子メールから選択クエリをコピーすると、誤ってスマート引用符が表示され、TAEF で解析できない可能性があります。 代わりに引用符を入力します。

複合選択条件の簡単な例とその実行内容を見てみましょう。

Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll \
/select:"@Owner='C2' AND @Priority=2"

次のコマンドを実行します。

  • 例\CPP.SelectionCriteria2.Example.dll - class21::method211
Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll \
/select:"@Owner='C2' AND @Priority=3"

次のコマンドを実行します。

  • 例\CPP.SelectionCriteria1.Example.dll - class11::method112
Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll \
/select:"@Owner='U3' oR @Priority=1"

次のコマンドを実行します。

  • 例\CPP.SelectionCriteria1.Example.dll - class11::method111
  • 例\CPP.SelectionCriteria2.Example.dll - class22::method221
Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll \
/select:"not(@BackwardsCompatibility=*)"

BackwardsCompatibility 値が指定されていないすべてのテストを実行します。 (次の項目を参照してください)。

  • 例\CPP.SelectionCriteria1.Example.dll - class11::method111、class12::method121
  • 例\CPP.SelectionCriteria2.Example.dll - class22::method221
Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll \
/select:"@Owner='C*'"

所有者の値が "C" で始まるすべてのテストを実行します(大文字小文字を区別しません)。 したがって、前のコマンドは、class21 (つまり method211) で\CPP.SelectionCriteria1.Example.dll and all tests in Examples\CPP.SelectionCriteria2.Example.dll 例のすべてのテストを実行します

Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll \
/select:"not(@BackwardsCompatibility=*) OR (@Owner='C*' AND @BackwardsCompatibility='*XP*')"

は、BackwardsCompatibility が指定されていないか、所有者名が "C" で始まり、backwardsCompatibilty 値に XP が含まれるすべてのテストを実行します。 括弧 "(" と ")" を使用して優先順位を指定する方法に注意してください。

この例では、これは選択的に実行されます。

  • 例\CPP.SelectionCriteria1.Example.dll - class11::method111、class12::method121、
  • 例\CPP.SelectionCriteria2.Example.dll - class21::method211、class22::method221
Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll /select:"@Owner='???'"

3文字のみを含むプロパティ所有者の値を条件として持つテストのみが実行されます。

この例では、これは "C" と一致し、実行のみになります。

  • 例\CPP.SelectionCriteria1.Example.dll - class12::method121
Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll /select:"@Priority>=1"

これは、プロパティ値が floatvalue である ">="、"<="、">"、および "<" を使用する方法の良い例です。

この例では、prority が指定されていない examples\CPP.SelectionCriteria2.Example.dll - class22::method221 を除くすべてのメソッドを実行します。 言い換えると、これは次のように実行されます。

  • 例\CPP.SelectionCriteria1.Example.dll - class11::method111、class11::method112、class12::method121
  • \CPP.SelectionCriteria2.Example.dll - class21::method211 の例。

"/select" は、"/list" "/listproperties" などの他のコマンド オプションと組み合わせて使用できることに注意してください。

スマートクォート

Outlook または Word 文書から選択条件をコピーしてコマンド プロンプトにコピーすると、選択条件にスマート引用符が表示されることがあります。 スマートクォートとは何かについての詳細情報を見つけることができます スマートクォート: コンピュータの消費を意味するテキストの隠された惨劇

スマートクォートを回避する簡単な方法はありません。最良の方法は、コマンド プロンプトにコピーしてクエリの引用符部分を再入力した後、選択条件のすべての "二重引用符と " 一重引用符" を削除することです。

Outlook でメッセージを作成するときにオフにするオプション設定があります。 Outlook のヘルプ ボックスに「スマートクォート」と入力して見つけます。

クイック名ベースの選択

TAEF では、コマンド プロンプトで '/name' コマンド ライン パラメーターを使用して、名前に基づいて簡単に選択できます。

/name:<test name with wildcards>

〜に相当します。

/select:@Name='<test name with wildcards>'

つまり、次のような名前に基づいて選択クエリを指定できるようになりました。

Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll \
/select:"@Name='*::class11::*'"

/name を使用して、より迅速に次のようにします。

Te.exe Examples\CPP.SelectionCriteria1.Example.dll Examples\CPP.SelectionCriteria2.Example.dll /name=*::class11::*

コマンド プロンプトで /name/select の両方が指定されている場合、/name は無視され、/select が優先されることに注意してください。