Bazel test migration

From JetBrains/intellij-community · View interactive version

Bazel test migration is an AI agent skill from the GitHub repository JetBrains/intellij-community. Migrate IntelliJ JPS module tests to Bazel; debug Bazel-only failures.

How to use this skill

Skill file

<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/bazel-test-migration/SKILL.md -->

Bazel Test Migration

Keep existing test behavior unless a failure proves that the test depends on an invalid environment assumption.

Establish the Baseline

During migration, run the Bazel target directly if bt refuses a module that is not yet marked as migrated.

Configure the Target

Follow the module dependencies skill for registration and generation.

Do not patch missing jars or descriptors into runfiles with copy_file.

Resolve Test Inputs

Use all three parts of the test data contract:

  1. Declare the required files in a filegroup, or reuse an existing one.
  2. Add that target to the test's data.
  3. Resolve the runtime path through an existing helper or BazelTestUtil.getFileFromBazelRuntime(BazelLabel).

Prefer a helper such as JavaTestUtil.getJavaTestDataPath() when it already supports Bazel.

Keep the existing non-Bazel behavior. Check static fields, companion properties, and serialization inputs as well as fixture path overrides.

Read test data and writable files for examples and VFS access handling.

For downloads or child builds, read external inputs and nested builds.

Debug Focused Failures

Run the failing class with fresh test results:

./bazel.cmd test --cache_test_results=no \
  --test_filter='com.example.ExampleTest' \
  @community//path/to/package:target_test

Use com.example.ExampleTest#testMethod for one method.

Avoid repeated full-module runs while diagnosing a focused failure.

Verify the Complete Target

Remove diagnostic selectors and run the exact target without a test filter:

./bazel.cmd test --cache_test_results=no @community//path/to/package:target_test

See discovery and sandbox checks for details.

Complete the Switch

Keep test data resolution changes separate from configuration changes when that makes review easier.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.