Decide where to place TiDB tests and how to write them (basic structure, naming, testdata usage). Use when asked about test locations, writing conventions, shard_count limits, casetest categorization, or when reviewing test changes in code review.
rg --files -g '*_test.go' and rg --files -g '*.json'.references/planner-guide.md.BUILD.bazel shard_count (practical target: <= 50 tests per directory; benchmarks excluded).BUILD.bazel and related wrappers such as Makefile bench-daily.func BenchmarkXxx) follow the same placement and naming rules, but do not count toward the directory test-count target.store + one tk per test; when a single test covers multiple scenarios, use distinct table names and restore any session/system variables to their original values.t.Run unless subtest isolation/parallel behavior is required by semantics..Check(testkit.Rows(...)); use MultiCheckContain only when output is inherently unstable, and add a short comment for why exact match is not practical.tk for *testkit.TestKit (avoid testKit).store and a single tk unless multi-session behavior is required; do not create a new store/tk inside the same test body without a documented reason.references/<pkg>-case-map.mdreferences/planner-guide.md*_in.json, *_out.json, *_xut.json) in the same directory when extending suites. Use -record -tags=intest,deadlock only when the Go test suite explicitly supports -record and you need to regenerate outputs. For tests/integrationtest, use the recording command in docs/agents/testing-flow.md -> Integration tests (not -record).pkg/planner/core/casetest/rule predicate pushdown cases, keep SQL in predicate_pushdown_suite_in.json and record both EXPLAIN format='brief' and query results via the test runner (see rule_predicate_pushdown_test.go).EXPLAIN format = 'plan_tree', but keep special-format suites unchanged. In particular, do not switch stats/analyze/load-stats-related tests (for example stats_test.go, planstats, analyze-focused CBO suites, and suites that depend on load stats) to plan_tree; cost-oriented assertions should prefer EXPLAIN format = 'cost_trace'; plan cache tests should keep explain for connection or format='plan_cache'; and hint tests should prefer plan_tree when the assertion is about the final chosen plan, while warning/applicability assertions may keep the nearby suite's existing format when that output is format-sensitive.TestBenchDaily wrappers that list them and keep Makefile bench-daily entries aligned with the new package location.pkg/* package, update the corresponding case map under references/ if it exists; do not block on missing case maps.references/ and updating this SKILL.md./* issue:12345 */) or nearby comments for traceability.tests/integrationtest for end-to-end coverage unless you need to avoid union-storage executor differences or require full workflow validation.go/runfiles and ensure the target file is exported via exports_files() in its owning BUILD.bazel.TEST_WORKSPACE) in the runfile path if needed..agents/skills/tidb-bazel-prepare-gate and docs/agents/testing-flow.md.