Skip to main content
rule CX Codex

testing-engineering — Claude Code rule for tests and setup

The testing-engineering Claude Code rule sets expectations for unit tests, project structure, and dependencies. It covers application layers, exception handling, and domain models.

MIT ★ 517 updated 2026-11-16

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/testing-engineering.md
Open on GitHub

What testing-engineering does

The rule defines unit-testing and project-structure standards. Tests must run automatically, remain independent, and produce repeatable results. They cover boundary values, valid input, and errors; assertions verify outcomes instead of printing them with System.out. Statement coverage must reach 70%, branch coverage 80%, and core modules require 100% statement coverage.

The document maps layers from Open API through DAO, assigns exception-handling behavior, and defines DO, DTO, BO, Query, and VO models. Internal dependencies follow GAV naming and versioning conventions; SNAPSHOT versions are forbidden. Storage designs and data structures require review and documentation. Business objects with more than three states need a state diagram.

For Claude Code, place the rule at .claude/rules/testing-engineering.md. Other supported IDEs use their own installation paths.

What it helps with

  • check that unit tests run independently and repeatably
  • set statement and branch coverage thresholds
  • separate responsibilities across application layers
  • standardize exception handling by layer
  • block dependencies on SNAPSHOT versions

Example prompts for the agent

  • Check the unit tests against the project rules.
  • Review the application layers and exception handling against the rules.
  • Check dependencies and state diagrams against the project rules.

How to install testing-engineering

Manually: put the files in place

.claude/rules/testing-engineering.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about testing-engineering

How do I install testing-engineering in Claude Code?

Place the rule at .claude/rules/testing-engineering.md.

What does testing-engineering do?

It sets requirements for unit tests, code coverage, application layers, exception handling, and internal dependencies.

What coverage thresholds does testing-engineering set?

Statement coverage must reach 70%, branch coverage must reach 80%, and core modules require 100% statement coverage.

Source text

testing-engineering.md · MIT
# Unit testing and project-structure guidelines

## Unit testing guidelines

### AIR principles
**Detection mode**: semantic

**Unit tests must follow the AIR principles (MULT-GEN-203):**

| Principle | Description |
|------|------|
| A - Automatic | Runs fully automatically without human intervention |
| I - Independent | Test cases are independent; they must not call or depend on each other |
| R - Repeatable | Repeatable, with stable and consistent results |

### Test conventions
**Detection mode**: semantic

```java
// Correct unit test (MULT-GEN-204)
@Test
public void testGetUserById() {
    // Given: prepare test data
    Long userId = 1L;
    User expectedUser = new User(userId, "test");
    when(userDao.findById(userId)).thenReturn(expectedUser);
    
    // When: invoke the method under test
    User actualUser = userService.getUserById(userId);
    
    // Then: verify the result
    assertNotNull(actualUser);
    assertEquals(expectedUser.getName(), actualUser.getName());
}
```

### BCDE principles
**Detection mode**: semantic

| Principle | Description |
|------|------|
| B - Border | Boundary-value testing (loop boundaries, numeric boundaries) |
| C - Correct | Correct input produces the expected result |
| D - Design | Write tests together with the design document |
| E - Error | Erroneous input produces the expected error output |

### Test coverage (MULT-GEN-208)
**Detection mode**: semantic

- Statement coverage >= 70%
- Core-module statement coverage = 100%
- Branch coverage >= 80%

### Testing anti-patterns
**Detection mode**: semantic

```java
// Wrong: verify with System.out (MULT-GEN-204)
@Test
public void testBad() {
    User user = userService.getUserById(1L);
    System.out.println(user.getName());  // Forbidden!
}

// Correct: verify with asserts
@Test
public void testGood() {
    User user = userService.getUserById(1L);
    assertNotNull(user);
    assertEquals("expected", user.getName());
}

// Wrong: test cases depend on each other (MULT-GEN-205)
@Test
public void testA() {
    // Set a static variable
    TestContext.value = 1;
}

@Test
public void testB() {
    // Depends on testA's result
    assertEquals(1, TestContext.value);  // Forbidden!
}
```

## Project structure guidelines

### Application layering
**Detection mode**: semantic

**Standard layered architecture (MULT-GEN-193):**

```
Open API layer → Client display layer → Web layer → Service layer → Manager layer → DAO layer
```

| Layer | Responsibility | Description |
|------|------|------|
| Open API layer | Wraps Service and exposes RPC/HTTP interfaces | Gateway security control, traffic control |
| Client display layer | Template rendering and display | velocity, JS, JSP, mobile |
| Web layer | Access control and forwarding, basic parameter validation | No business reuse; keep processing simple |
| Service layer | Concrete business logic | Business encapsulation, composed calls |
| Manager layer | Common business processing, third-party preprocessing | Shared Service capabilities (cache, middleware), composition and reuse of multiple DAOs |
| DAO layer | Data access | MySQL, Oracle, Hbase, etc. |

### Exception handling by layer (MULT-GEN-194)
**Detection mode**: semantic

| Layer | Exception handling |
|------|-------------|
| DAO layer | catch → throw DAOException, no logging |
| Service layer | Must log to disk with parameter information |
| Manager layer | Like DAO when co-located; like Service when independently deployed |
| Web layer | Do not rethrow; redirect to a friendly error page |
| API layer | Convert to an error code + error message |

### Domain model conventions (MULT-GEN-195)
**Detection mode**: semantic

| Model | Description | Use case |
|------|------|---------|
| DO | Object corresponding to a database table | Passed upward by the DAO layer |
| DTO | Data transfer object | Passed outward by Service/Manager |
| BO | Business object | Business-logic encapsulation in the Service layer |
| Query | Query request object | Receives query parameters at each layer; Map is forbidden with more than 2 parameters |
| VO | Display-layer object | Passed from Web to the template engine |

### Internal library dependency conventions (MULT-GEN-196/197/198)
**Detection mode**: semantic

**GAV format conventions:**

| Convention | Description | Example |
|------|------|------|
| GroupID | com.{company/BU}.business-line.[sub-business-line] | `com.example.order` |
| ArtifactID | product-line-name-module-name | `passenger-order-api` |
| Version | major.minor.patch | `1.0.0` |

**Version numbering rules:**

| Version type | Description |
|---------|------|
| Major version | Incompatible API changes |
| Minor version | Backward-compatible feature additions |
| Patch version | Backward-compatible bug fixes |

**Dependency rules:**

```xml
<!-- Wrong: depend on a SNAPSHOT version -->
<dependency>
    <version>1.0.0-SNAPSHOT</version>  <!-- Forbidden! -->
</dependency>

<!-- Correct: depend on a release version -->
<dependency>
    <version>1.0.0</version>
</dependency>

<!-- Correct: use a shared version variable -->
<dependency>
    <version>${spring.version}</version>
</dependency>
```

### Design conventions (MULT-GEN-199/200/201/202)
**Detection mode**: semantic

| Rule | Description |
|------|------|
| Storage design review | Storage designs and data structures must be reviewed and documented |
| State diagrams | Use a state diagram when a business object has more than 3 states |
| Single responsibility | Class design follows the single-responsibility principle |
| Composition over inheritance | Prefer aggregation/composition; use inheritance cautiously |

© kyy-logs · MIT · kyy-logs/code-review-gate-skill

Similar IDE rules

All IDE rules for Testing and QA →
131-java-testing-unit-testing Juan Antonio Breña Moral 131-java-testing-unit-testing is a Claude Code skill that reviews and improves Java unit tests with JUnit 5, AssertJ, and Mockito, catching anti-patterns and checking boundary conditions. CX Codex +1 479installs 521-frameworks-micronaut-testing-unit-tests Juan Antonio Breña Moral 521-frameworks-micronaut-testing-unit-tests enforces unit testing standards for Micronaut apps: prefers fast Mockito tests without context boots and reserves @MicronautTest for HTTP or @MockBean setups. CX Codex +1 324installs spring-boot-dependency-injection giuseppe-trisciuoglio spring-boot-dependency-injection sets up constructor-first dependency injection patterns for Spring Boot projects. It eliminates field injection and organizes bean selection via @Primary and @Qualifier. CX Codex +1 4,000installs testing-changes riekelt testing-changes defines test requirements for code changes, enforcing regression tests for bug fixes, edge-case coverage, and strict checks against empty test diffs. CX Codex +1 25,600installs swift-testing-pro Paul Hudson swift-testing-pro — a skill for Claude Code, Codex, Cursor and other agents that writes, audits, and fixes Swift Testing code against Swift 6.2 APIs. Covers async tests, actor isolation, XCTest migration, and new framework features. CX Codex +1 10,900installs testing Mindrally Defines software testing guidelines for AI agents, covering test isolation, table-driven checks, and mock boundaries. CX Codex +1 888installs

From the same set10

The whole set →
baseline-java The baseline-java Claude Code rule adds Java checks for security, concurrency, and exception handling. It applies during Java code review. CX Codex +1 ★ 517repo stars spring-performance spring-performance is a Claude Code rule for Spring/JPA practices and performance tuning. It guides agents working on Java code, database queries, and server settings. CX Codex +1 ★ 517repo stars spring-performance The spring-performance Claude Code rule sets Spring/JPA and performance checks. It flags issues in validation, transactions, queries, and batch operations. CX Codex +1 ★ 517repo stars concurrency This Claude Code rule sets Java concurrency guidelines. It covers thread pools, locks, shared records, and other sources of concurrent access bugs. CX Codex +1 ★ 517repo stars exception-logging exception-logging — a rule for Claude Code that enforces Java exception handling and logging standards. Runs during code review to catch empty catch blocks, unmasked data, and missing transaction rollbacks. CX Codex +1 ★ 517repo stars naming-format The naming-format Claude Code rule sets Java naming and formatting conventions. It covers classes, methods, constants, and control flow. CX Codex +1 ★ 517repo stars code-review-gate The code-review-gate Claude Code skill reviews code changes before a commit or PR merge. It gathers the diff, checks test quality, and records issues. CX Codex +1 ★ 517repo stars oop-collection The oop-collection Claude Code rule sets guidelines for Java objects and collections. It covers null checks, object comparisons, and safe list updates. CX Codex +1 ★ 517repo stars

Project sponsors

Companies that keep this analytics open