mcpField
I
integration-tests

integration-tests

github.com/microsoftテスト・品質194.4k198 回インストール今日更新
リポジトリ

integration-tests について

VS Code の統合テスト実行を支援するリポジトリ向けスキルです。Node.js 統合テストと拡張機能ホストのテストスイートの選択、絞り込み、コンパイル要件を説明します。

主な機能

  1. 01Node.js 統合テストの実行
  2. 02拡張機能ホストのテストスイート実行
  3. 03ファイル、パス、スイート、名前で選択
  4. 04ビルド出力とテスト範囲の選択
  5. 05テストスクリプトの使い分けを把握

活用シーン

  1. 01単一の統合テストファイルを実行
  2. 02テスト名やファイル glob で絞り込み
  3. 03指定した拡張機能ホストのスイートを実行
  4. 04統合テストとユニットテストを区別

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/microsoft/vscode --skill integration-tests

インストール後、Claude Code で/integration-testsを入力して読み込まれたか確認します。

詳細

統合テストの実行

VS Code の統合テストは、次の 2 つのカテゴリに分かれています。

  1. Node.js 統合テスト - src/ 配下にある、.integrationTest.ts で終わるファイルです。ユニットテストと同じ Mocha ランナーを使用し、Electron 上で実行されます。
  2. 拡張機能ホストテスト - extensions/ 配下にある組み込み拡張機能に含まれるテスト(API テスト、Git テスト、TypeScript テストなど)です。--extensionDevelopmentPath を指定して、VS Code のインスタンス全体を起動します。

スクリプト

  • macOS / Linux: ./scripts/test-integration.sh [options]
  • Windows: .\scripts\test-integration.bat [options]

フィルターを指定せずに実行すると、どちらのスクリプトもすべての Node.js 統合テストに続いて、すべての拡張機能ホストテストを実行します。決定論的な Agent Host E2E スイートは実行しません。これらは ./scripts/test-agent-host-e2e.sh(または .\scripts\test-agent-host-e2e.bat、または npm run test-agent-host-e2e)で実行します。各スイートは、並列に、それぞれ独立したテストプロセスで実行されます。GitHub CI では、統合テストと並列に Windows 上の別ジョブ Agent-Host-E2E / Windows で実行され、Linux と macOS では 🧪 Run integration tests (Electron) の前に別のステップとして実行されます。ADO では、Integration Tests (Electron) ジョブ(integration-electron)ではなく、別の Agent Host E2E Tests (Electron) ジョブでテスト ID integration-agent-host-e2e として実行されます。src/vs/platform/agentHost/test/node/e2e/README.md を参照してください。--run では、引き続き Agent Host E2E ファイルを 1 つ指定できます。

--run または --runGlob を指定して実行すると(--suite を指定しない場合)、Node.js 統合テストのみが実行され、フィルターが適用されます。これらのフィルターは Node.js 専用のため、拡張機能ホストテストはスキップされます。

--grep のみを指定して実行すると(--run、--runGlob、--suite は指定しない場合)、すべてのテストが実行されます。つまり、Node.js 統合テストとすべての拡張機能ホストスイートの両方が実行され、grep パターンがすべてのテストランナーに渡されます。

--suite を指定して実行すると、一致する拡張機能ホストテストスイートのみが実行されます。Node.js 統合テストはスキップされます。--suite と --grep を組み合わせると、選択したスイート内の個々のテストをフィルターできます。

オプション

--build - ビルド出力に対して実行

Node.js 統合テストと、スタンドアロンの JSON スイートで使用される共有 VS Code モジュールに対して、out/ の代わりに out-build/ ディレクトリを選択します。どちらの出力ツリーもコンパイルしません。JSON 拡張機能テストでは、client/out/ を生成するために引き続き compile-extension:json-language-features-client が必要です。

./scripts/test-integration.sh --suite json --build
--run <file> - 特定のファイルのテストを実行

ソースファイルのパス(src/ で始まるもの)を指定できます。scripts/test.sh --run と同じように動作します。

./scripts/test-integration.sh --run src/vs/workbench/services/search/test/browser/search.integrationTest.ts
--runGlob <pattern>(別名:--glob、--runGrep)- パスでテストファイルを選択

glob パターンに一致するコンパイル済みの .js ファイルパスを基に、読み込むテストファイルを選択します。デフォルトの **/*.integrationTest.js glob を上書きします。Node.js 統合テストにのみ適用されます(拡張機能ホストテストはスキップされます)。

./scripts/test-integration.sh --runGlob "**/search/**/*.integrationTest.js"
--grep <pattern>(別名:-g、-f)- テスト名でテストケースをフィルター

テストタイトル(例:describe/test の名前)との一致に基づいて、実行するテストケースをフィルターします。単独で使用すると、Node.js 統合テストとすべての拡張機能ホストスイートの両方に grep が適用されます。--suite と組み合わせると、一致するスイートのみが grep を適用して実行されます。

./scripts/test-integration.sh --grep "TextSearchProvider"
--suite <pattern> - 特定の拡張機能ホストテストスイートを実行する

名前がパターンに一致する拡張機能ホストテストスイートのみを実行します。カンマ区切りの値とシェルのグロブパターン(macOS/Linux)に対応しています。Node.js 統合テストはスキップされます。

利用可能なスイート名:api-folder、api-workspace、colorize、terminal-suggest、typescript、markdown、emmet、git、git-base、ipynb、notebook-renderers、configuration-editing、github-authentication、copilot、css、html、json。

css、html、json スイートは、ワークベンチを開かず、Electron の Node.js モードで実行される単独の拡張機能テストです。これらのスイートでは、拡張機能ホストテストと同じスイート選択および grep フィルタリングが適用されます。

# Run only Git extension tests
./scripts/test-integration.sh --suite git

# Run API folder and workspace tests (glob, macOS/Linux only)
./scripts/test-integration.sh --suite 'api*'

# Run multiple specific suites
./scripts/test-integration.sh --suite 'git,emmet,typescript'

# Filter tests within a suite by name
./scripts/test-integration.sh --suite api-folder --grep 'should open'
--only-node-tests、--only-extension-host-tests - いずれか一方を実行する

Node.js 統合テストのみ、または拡張機能ホストテストのみ(css、html、json を含むすべてのスイート)を実行します。--grep はどちらにも適用されます。--only-node-tests は --suite と併用できません。また、--only-extension-host-tests は --run または --runGlob と併用できません。

GitHub のプルリクエスト CI では、2 つのパートを別々のステップとして実行します。🧪 Run integration tests (Electron) は Node.js 統合テストを実行し、失敗したテストを再実行します(--rerun-failed-files 2)。🧪 Run extension host integration tests (Electron) は拡張機能ホストスイートを実行します。このテストは再実行されません。また、統合テストまたは Agent Host E2E が失敗した場合にも実行されます。

./scripts/test-integration.sh --only-node-tests --rerun-failed-files 2
./scripts/test-integration.sh --only-extension-host-tests
--help、-h - ヘルプを表示する
./scripts/test-integration.sh --help
その他のオプション

その他のオプション(例:--timeout、--coverage、--reporter)は、Node.js 統合テスト用の基盤となる scripts/test.sh ランナーに渡されます。--suite を使用する場合、これらの追加オプションは拡張機能ホストスイートには渡されません。

例

# Run all integration tests (node.js + extension host)
./scripts/test-integration.sh

# Run a single integration test file
./scripts/test-integration.sh --run src/vs/workbench/services/search/test/browser/search.integrationTest.ts

# Run integration tests matching a grep pattern
./scripts/test-integration.sh --grep "TextSearchProvider"

# Run integration tests under a specific area
./scripts/test-integration.sh --runGlob "**/workbench/**/*.integrationTest.js"

# Run only Git extension host tests
./scripts/test-integration.sh --suite git

# Run API folder + workspace extension tests (glob)
./scripts/test-integration.sh --suite 'api*'

# Run multiple extension test suites
./scripts/test-integration.sh --suite 'git,typescript,emmet'

# Grep for specific tests in the API folder suite
./scripts/test-integration.sh --suite api-folder --grep 'should open'

# Combine file and grep
./scripts/test-integration.sh --run src/vs/workbench/services/search/test/browser/search.integrationTest.ts --grep "should search"

コンパイル要件

テストはコンパイル済みの JavaScript 出力に対して実行されます。テストを実行する前に、VS Code - Build ウォッチタスクが実行中であること、またはコンパイルが完了していることを確認してください。

ユニットテストとの違い

  • ユニットテスト(.test.ts)→ scripts/test.sh または runTests ツールを使用します
  • 統合テスト(.integrationTest.ts および拡張機能テスト)→ scripts/test-integration.sh を使用します

混同しないでください。scripts/test.sh は、--runGlob **/*.integrationTest.js を明示的に渡さない限り、統合テストファイルを検出しません。また、scripts/test-integration.sh は .test.ts ファイルを対象としていません。

コメント