实现或修改 IntelliJ `AnAction`,并在 `plugin.xml` 中注册。将显示名称和说明写入消息资源文件,按需设置图标,并通过事件协程作用域启动挂起任务,避免同步处理阻塞 IDE。
- 为 IDE 菜单添加操作
- 修改操作注册或图标
- 整理操作名称和说明
使用 `bt.cmd` 或 `tests.cmd` 运行 IntelliJ 测试,并排查测试选择、模块归属、未发现和构建失败等问题。
Run or troubleshoot IntelliJ tests with `bt.cmd` or `tests.cmd`.
实测评分 未实测
查看安装方法本技能协助运行 IntelliJ 测试,并说明如何指定测试类、方法或包。Bazel 支持的模块使用 bt.cmd;尚不支持的模块则切换到 tests.cmd。如果找不到测试类,会检查完整限定名、通配符模式以及包含该测试的 JPS 模块。仅使用简单类名无法匹配。
测试失败时,可以根据退出码区分测试失败、构建失败和基础设施故障。技能还说明如何重试失败的测试、设置测试 JVM 内存、传递系统属性,以及连接调试器。对于独立的 Bazel 模块测试和产品打包变更,也会说明相应的运行方式。
需要单独运行 IntelliJ 的某项测试,或排查测试找不到、内存不足、构建前失败等问题时,可以使用本技能。测试所属模块不明确,或需要判断应使用 bt.cmd 还是 tests.cmd 时也适用。
tests.cmd 找不到这个测试的原因。”运行测试需要目标代码库的构建环境。独立 Bazel 模块中的测试必须按照该模块的说明通过 Bazel 运行。
本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。
AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。
不计入评分。 由 AI(OpenAI Codex)于 2026年10月28日 评估。仅供参考,安装前请同时查看原文。
安装前可以查看交给 AI 代理的指令内容。
Run the tests of a module with bt first:
./community/tools/bt.cmd --module <module> --filter <FQN>
--module: the JPS module that holds the test classes. Always use the module of the test itself. The module name is the name of the .iml file in the test directory, without the extension.--filter: an FQN, FQN#method, or an all-lowercase package. A package value runs all the test classes in that package.In a community checkout, the wrapper is ./tools/bt.cmd.
# Single test class (FQN)
./community/tools/bt.cmd --module intellij.platform.util.tests \
--filter com.intellij.openapi.util.io.FileUtilLightTest
# Specific test method
./community/tools/bt.cmd --module intellij.platform.util.tests \
--filter 'com.intellij.openapi.util.io.FileUtilLightTest#isAncestor'
# All test classes of a package
./community/tools/bt.cmd --module intellij.platform.util.tests \
--filter com.intellij.openapi.util.io
bt runs a module when the migrated list names it, or when a bt.json area owns its directory. The bt README gives the resolution rules.
| Option | Effect |
|---|---|
--filter <value> | Runs one class, one method, or one package of the target. |
--no-cache | Runs the tests again when Bazel has a cached result. |
--dry-run | Prints the resolved label, the filter, and the Bazel command. Runs nothing. |
--json | Writes one JSON object to stdout and nothing else. |
--host <host> | Runs the committed HEAD on another machine of the user over yonder. The yonder skill (yonder skill install) gives the rules. |
-- --flaky_test_attempts=3 | Runs a failed test up to 3 times. tests.cmd uses -Dintellij.build.test.attempt.count=3 for this. |
-- --test_arg=--jvm_flag=-Dkey=value | Sets a system property in the test JVM. tests.cmd uses -Dpass.key=value for this. |
-- --test_arg=--jvm_flag=-Xmx8g | Sets the heap of the test JVM. tests.cmd uses -Dintellij.build.test.jvm.memory.options=-Xmx8g for this. |
bt gives all arguments after -- to Bazel without a change. Run ./community/tools/bt.cmd --help for all selectors and options. To attach a debugger, use tests.cmd. The section Additional JVM options shows the flags.
| Exit code | Meaning |
|---|---|
| 0 | All tests passed. |
| 2 | Usage error, or bt refuses the module. |
| 3 | Tests failed. |
| 4 | Zero tests ran. |
| 5 | The build failed before the tests. |
| 6 | Infrastructure failure. |
bt buildA green bt run in a linked work tree, such as a Branch Deck lease, records the tree that it saw: one line in bd-checks.jsonl of the git directory. bd lease pick reads the record. A repository can set pick_requires_check in .branchdeck.toml, and then the pick refuses a lease whose tree has no green build or test. A run during which the files changed records nothing. A red run records nothing.
Check the last tree with bt, not with a raw ./bazel.cmd build. bazel.cmd gives the process to bazelisk, so it leaves no record. Commit or delete scratch files before the last check: a record of local changes counts only for a commit of the same files, and bt names those files on the stderr.
./community/tools/bt.cmd build //plugins/air/... # bazel build -k, one digest line, and the record
./community/tools/bt.cmd build //plugins/air/... --host studio
bt build exits 0 for a green build, 5 for a build failure, and 6 for an infrastructure failure. A --host run records the tree of the commit that ran on the host. The bt README gives the record format.
bt refuses a module whose tests do not run under Bazel yet. It exits with code 2 and prints the tests.cmd command. Run that command:
./tests.cmd --module <module> --test <pattern>
--module — the JPS module containing the test classes (always use the test's own module). To find the module name, look at the .iml file in the test's directory — the module name is the .iml filename without the extension.--test — FQN, wildcard pattern, or FQN#methodName# Single test class (FQN)
./tests.cmd --module intellij.cidr.compiler.custom.tests \
--test com.intellij.cidr.compiler.custom.CidrCustomCompilerReadTest
# Wildcard pattern
./tests.cmd --module intellij.goland.tests \
--test com.goide.comments.*Test
# Specific test method (wildcards cannot be used with #)
./tests.cmd --module intellij.cidr.compiler.custom.tests \
--test com.intellij.cidr.compiler.custom.CidrCustomCompilerReadTest#testSingleDefine
# Multiple (semicolon-separated)
./tests.cmd --module intellij.platform.build.tests \
--test org.jetbrains.intellij.build.TestSelectorsTest#class selector;org.jetbrains.intellij.build.FileSetTest
Simple class names like MyTest do NOT work — always use FQN or wildcard (*MyTest).
Patterns are transformed (* → .*, . → \.) and matched against the fully qualified class name using Pattern.matches() (full-string match):
| Pattern | Regex | Matches org.example.MyTest? |
|---|---|---|
MyTest | MyTest | NO — doesn't cover the package prefix |
*MyTest | .*MyTest | YES |
org.example.MyTest | org\.example\.MyTest | YES |
org.example.* | org\.example\..* | YES |
Use community/tests.cmd for tests that belong to community-only modules:
./community/tests.cmd --module <module> --test <pattern>
In an Ultimate checkout, run ApiCheckTest directly through its Bazel test target. For a focused check, pass one or more comma-separated module names:
bazel test //tests/ideaProjectStructure:projectStructureTests_test \
--test_filter=com.intellij.ideaProjectStructure.api.ApiCheckTest \
--test_arg=--jvm_flag=-Dapi.dump.test.modules.to.check=<module>[,<module>...] \
--test_output=summary \
--test_summary=detailed
Omit --test_arg to check all modules. Do not use bazel run for this target: it streams noisy test output and does not provide Bazel's test summary.
This bt command is the same run with a digest:
./community/tools/bt.cmd //tests/ideaProjectStructure:projectStructureTests_test \
--filter com.intellij.ideaProjectStructure.api.ApiCheckTest \
-- --test_arg=--jvm_flag=-Dapi.dump.test.modules.to.check=<module>[,<module>...]
On failure, keep agent context small by extracting the failing dynamic-test names and messages from Bazel's JUnit report instead of printing the full test.log:
xmllint --xpath '//testcase[failure or error]/@name | //testcase[failure or error]/*[self::failure or self::error]/@message' \
out/bazel-testlogs/tests/ideaProjectStructure/projectStructureTests_test/test.xml
When changing ProductProperties, productImplementationModules, product content descriptors, plugin/module-set packaging, or generated product layout XML, also run:
./community/tools/bt.cmd //build:all-products-packaging_test
The target pins the one class AllProductsPackagingTest and is tagged manual, so no --filter is needed, and no lane or wildcard pattern runs it. bt prints the digest, and Bazel writes out/bazel-testlogs/build/all-products-packaging_test/test.xml. The raw form is ./bazel.cmd test //build:all-products-packaging_test.
When running tests.cmd from PowerShell, pass JVM -D... arguments via stop-parsing mode to avoid argument mangling:
./tests.cmd --% -Dintellij.build.test.patterns=com.example.MyTest
Without --%, PowerShell can alter -D... arguments before they reach tests.cmd, which may lead to errors like Could not find or load main class ....
Some parts of the repository are standalone Bazel modules and must not use tests.cmd or community/tests.cmd. The tests of a module that matches a pattern in the migrated list run only under Bazel. The migrated list is community/build/bazel-migrated-test-modules.txt, or build/bazel-migrated-test-modules.txt in a community checkout. tests.cmd refuses such a module with an error that names the pattern. Run the module with bt:
./community/tools/bt.cmd --module <module> --filter <FQN>
When you have the Bazel label of the target, ./community/tools/bt.cmd <label> --filter <FQN> runs the same target.
community/platform/build-scripts/bazelcommunity/platform/build-scripts/bazel/README.md:cd community/platform/build-scripts/bazel
../../../../bazel.cmd test //:bazel-generator-integration-tests --test_output=all
./tests.cmd for org.jetbrains.intellij.build.bazel.BazelGeneratorIntegrationTests or other tests in that module.community/platform/build-scripts/bazel, prefer that module-local ../../../../bazel.cmd test flow for verification.tests.cmd is a cross-platform script (works on Windows/Linux/macOS)--module and --test, maps them to JVM properties, and calls bazel run //build:local_idea_ultimate_run_tests_build_targetTroubleshooting test discovery:
bazel cleanFor deeper troubleshooting, see TESTING-internals.md.
Usage: tests.cmd --module <module> --test <pattern> [options]
Required:
--module <module> Name of the JPS module which contains the test classes
--test <pattern> Full test class name (FQN) or wild card pattern (e.g. com.intellij.*Test) or exact FQN#methodName
Options:
--debug Debug build scripts JVM process
--help Show this help message
Additional options are passed as JVM flags to org.jetbrains.intellij.build.TestingOptions
Example: -Dintellij.build.test.debug.enabled=true -Dintellij.build.test.debug.suspend=true -Dintellij.build.test.debug.port=5005
Extra -D... arguments are passed through as JVM flags to org.jetbrains.intellij.build.TestingOptions:
-Dintellij.build.test.attempt.count=<n>
-Dintellij.build.test.jvm.memory.options=<options>
-Xmx8g for 8GB heap-Dpass.<property>=<value>
pass. prefix is stripped, so -Dpass.my.flag=true becomes -Dmy.flag=true in the test JVMDebugging: -Dintellij.build.test.debug.enabled=true -Dintellij.build.test.debug.port=5005 -Dintellij.build.test.debug.suspend=true — attach IDE debugger to port 5005.
Tests fail with OutOfMemoryError:
-Dintellij.build.test.jvm.memory.options=-Xmx8gTests not found:
--test uses FQN or wildcard, not simple class name: --test com.example.MyTest--module is the module that actually contains the test class (look at the .iml file location)community/platform/build-scripts/bazel; those tests must be run with module-local ../../../../bazel.cmd test, not tests.cmdtests.cmd refuses the module and names a pattern from bazel-migrated-test-modules.txt, the tests are Bazel-only. Run them with ./community/tools/bt.cmd --module <module> --filter <FQN>, as in Separate Bazel ModulesTests pass locally but fail in CI:
-Dintellij.build.test.attempt.count=3 for flaky testsBazel build fails before tests run:
.iml fileFor deeper troubleshooting, see TESTING-internals.md.
For detailed information about how tests.cmd works internally, including:
For guidelines on writing tests (as opposed to running them), see the guidelines:
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
实现或修改 IntelliJ `AnAction`,并在 `plugin.xml` 中注册。将显示名称和说明写入消息资源文件,按需设置图标,并通过事件协程作用域启动挂起任务,避免同步处理阻塞 IDE。
将 IntelliJ JPS 测试模块迁移到 Bazel,并排查仅在 Bazel 中出现的失败。根据症状检查依赖、插件、测试数据和 runfiles,重新生成并验证目标。
按 IntelliJ 项目规范编写或审查 Kotlin 和 Java 代码,涵盖语言选择、格式、密封类型、线程注解及控制流异常处理。
本指南帮助您按 IntelliJ 项目规则拆分更改并撰写提交信息:有工单时使用编号和变更说明,无工单时使用标签与子系统名,并在需要时说明原因和决定。
使用多个 Python 类型检查器比较代码片段或文件的类型推断和报错判断,并汇总各工具的结论、耗时与诊断信息,可保存为 Markdown 报告。
整理 Compose Desktop 界面中的状态和副作用,让可组合函数负责绘制,由展示器或协调器处理应用决策。了解状态归属、Effect、可复用组件接口、延迟列表键、动画和性能,适用于单项界面修改。