.agents/skills/testing/SKILL.md
Comprehensive testing reference for running tests in the IntelliJ IDEA codebase.
Run a single test class (use FQN or wildcard - simple names don't work):
# Option 1: Fully qualified name (recommended)
./tests.cmd -Dintellij.build.test.patterns=com.example.MyTest
# Option 2: Wildcard prefix
./tests.cmd -Dintellij.build.test.patterns=*MyTest
Some parts of the repository are standalone Bazel modules and must not use tests.cmd or community/tests.cmd.
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.Simple class names like MyTest do NOT work. You must use FQN or wildcard.
* → .*, . → \.org.example.MyTestPattern.matches() which requires FULL STRING MATCH| Pattern | Regex | Matches org.example.MyTest? |
|---|---|---|
MyTest | MyTest | ❌ NO |
*MyTest | .*MyTest | ✅ YES |
org.example.MyTest | org\.example\.MyTest | ✅ YES |
org.example.* | org\.example\..* | ✅ YES |
# ✅ FQN (most reliable)
-Dintellij.build.test.patterns=org.jetbrains.idea.devkit.inspections.internal.JavaIoFileUsageInspectionTest
# ✅ Wildcard prefix (convenient)
-Dintellij.build.test.patterns=*JavaIoFileUsageInspectionTest
# ✅ Package wildcard
-Dintellij.build.test.patterns=org.jetbrains.idea.devkit.inspections.*Test
# ✅ Multiple patterns (semicolon-separated)
-Dintellij.build.test.patterns=*MyTest;*OtherTest
# ❌ WRONG - Simple name (will NOT work)
-Dintellij.build.test.patterns=JavaIoFileUsageInspectionTest
tests.cmd is a cross-platform script (works on Windows/Linux/macOS)bazel run //build:idea_ultimate_run_tests_build_targetTroubleshooting test discovery:
bazel cleanFor deeper troubleshooting, see TESTING-internals.md.
The tests.cmd script supports the following parameters:
-Dintellij.build.test.attempt.count=<n>
-Dintellij.build.test.main.module=<module>
-Dintellij.build.test.jvm.memory.options=<options>
-Xmx8g for 8GB heapWhen running tests, the mainModule parameter determines which module's classpath is used for test discovery. Tests must be in the dependency tree of the specified module to be found.
| Product | tests.cmd Location | Default mainModule |
|---|---|---|
| IDEA Ultimate | ./tests.cmd | intellij.idea.ultimate.tests.main |
| Community | ./community/tests.cmd | intellij.idea.community.main.tests |
For complete list, see: intellij-teamcity-config/.teamcity/src/ijplatform/KnownModules.kt
| Product | Test Module |
|---|---|
| IDEA Ultimate | intellij.idea.ultimate.tests.main |
| IDEA Community | intellij.idea.community.main.tests |
| GoLand | intellij.goland.tests |
| PyCharm | intellij.python.tests |
| RubyMine | intellij.rubymine.aggregator |
| CLion | intellij.clion.main.tests |
| PhpStorm | intellij.phpstorm.main.tests |
| RustRover | intellij.rustrover.main.tests |
| Kotlin K2/FIR | kotlin.fir-all-tests |
If your test is not in the default module's dependency tree, specify the module explicitly:
# K2/FIR tests (not in default classpath)
./tests.cmd -Dintellij.build.test.patterns=org.jetbrains.idea.devkit.k2.inspections.K2JavaIoFileUsageInspectionTest \
-Dintellij.build.test.main.module=intellij.devkit.kotlin.fir.tests
# GoLand tests
./tests.cmd -Dintellij.build.test.patterns=*GoCommentReferencesTest \
-Dintellij.build.test.main.module=intellij.goland.tests
If tests.cmd reports "No tests found":
-Dintellij.build.test.main.module=<your-test-module>-Dintellij.build.test.simple.patterns=<selectors>
FullyQualifiedClassName or FullyQualifiedClassName#methodName-Dintellij.build.test.simple.patterns=org.jetbrains.intellij.build.TestSelectorsTest#class selector-Dintellij.build.test.simple.patterns=org.jetbrains.intellij.build.TestSelectorsTest#class selector;org.jetbrains.intellij.build.FileSetTest-Dintellij.build.test.patterns=<pattern>
-Dintellij.build.test.patterns=com.goide.comments.GoCommentReferencesTest-Dintellij.build.test.patterns=com.goide.*.GoCommentTest;com.goide.*.GoReferenceTest-Dintellij.build.test.groups=<group>
testGroups.properties filesALL_EXCLUDE_DEFINED_GROUP - Tests not included in any group (default)ALL - All tests-Dintellij.build.test.configurations=<config>
-Dintellij.build.test.configurations=Go TestsFast execution for a single test class:
./tests.cmd \
-Dintellij.build.test.patterns=com.goide.comments.GoCommentReferencesTest
Use simple patterns to run a single test method without wildcards:
./tests.cmd \
-Dintellij.build.test.simple.patterns=org.jetbrains.intellij.build.TestSelectorsTest#class selector
Multiple methods or a mix of classes and methods:
./tests.cmd \
'-Dintellij.build.test.simple.patterns=org.jetbrains.intellij.build.TestSelectorsTest#class selector;org.jetbrains.intellij.build.FileSetTest'
Automatically retry failed tests:
./tests.cmd \
-Dintellij.build.test.patterns=com.example.FlakyTest \
-Dintellij.build.test.attempt.count=3
Use patterns with wildcards:
./tests.cmd \
-Dintellij.build.test.patterns=com.goide.comments.*Test
For memory-intensive tests:
./tests.cmd \
-Dintellij.build.test.patterns=com.example.MemoryIntensiveTest \
-Dintellij.build.test.jvm.memory.options=-Xmx8g
To pass arbitrary system properties to the test process, use the pass. prefix:
./tests.cmd \
-Dintellij.build.test.patterns=com.example.MyTest \
-Dpass.my.custom.property=myValue
The pass. prefix is stripped, so the test JVM receives -Dmy.custom.property=myValue.
Combined example with memory and properties:
./tests.cmd \
-Dintellij.build.test.patterns=com.example.MyTest \
-Dintellij.build.test.jvm.memory.options="-Xmx4g" \
-Dpass.idea.is.unit.test=true \
-Dpass.my.debug.flag=enabled
Execute all tests in a specific group:
./tests.cmd \
-Dintellij.build.test.groups=CRITICAL_TESTS
Execute a named JUnit run configuration:
./tests.cmd \
"-Dintellij.build.test.configurations=Go Tests"
-Dintellij.build.test.attempt.count=3 for known flaky testsTo attach a debugger to the test JVM:
./tests.cmd \
-Dintellij.build.test.patterns=com.example.MyTest \
-Dintellij.build.test.debug.enabled=true \
-Dintellij.build.test.debug.port=5005 \
-Dintellij.build.test.debug.suspend=true
Then attach your IDE debugger to port 5005. The test process will wait for the debugger before starting.
Performance tests have class or method names containing "Performance". By default, they are excluded from regular test runs.
./tests.cmd \
-Dintellij.build.test.patterns=*PerformanceTest \
-Dpass.idea.performance.tests=true
Note: When idea.performance.tests=true, debugging is automatically disabled.
./tests.cmd \
-Dintellij.build.test.patterns=com.example.* \
-Dpass.idea.include.performance.tests=true
A test is considered a "performance test" if its class name or method name contains the word "performance" (case-insensitive). See TestFrameworkUtil.isPerformanceTest().
Similarly, "stress tests" contain "stress" or "slow" in their names.
By default, only test classes ending with Test are discovered. To include tests with unconventional names (like *Tests, *TestCase, *Suite, or names containing Test elsewhere):
./tests.cmd \
-Dintellij.build.test.patterns=*MySuite \
-Dpass.idea.include.unconventionally.named.tests=true
Without idea.include.unconventionally.named.tests:
Test are discoveredWith idea.include.unconventionally.named.tests=true:
Test or Suite anywhere in their nameNameUtilCore.nameToWordList)MyTestCase, AllTests, TestSuite, MySuiteRunnerTesting, Contest (no word boundary)Tests fail with OutOfMemoryError:
-Dintellij.build.test.jvm.memory.options=-Xmx8gTests not found:
-Dintellij.build.test.patterns=com.example.MyTestTest (or use -Dpass.idea.include.unconventionally.named.tests=true)main.module, check whether the test lives in a separate Bazel module such as community/platform/build-scripts/bazel; those tests must be run with module-local ../../../../bazel.cmd test, not tests.cmd-Dpass.idea.performance.tests=true or -Dpass.idea.include.performance.tests=trueTests 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: