@nguyenhuuca/testing
BWrite effective tests for code quality and reliability. Use when implementing features, fixing bugs, or improving coverage. Covers unit, integration, and E2E testing.
Install
agr install @nguyenhuuca/testing --target claudeWrites 1 file into .claude/skills/, pinned to git-b76c03b0.
- .claude/skills/testing/SKILL.md
Document
name: testing description: Write effective tests for code quality and reliability. Use when implementing features, fixing bugs, or improving coverage. Covers unit, integration, and E2E testing. allowed-tools: Read, Write, Edit, Bash, Glob, Grep, mcp__chrome-devtools__*
Testing Software
MCP Tools
Chrome DevTools (E2E testing):
- Automate user flows in real browser
- Capture screenshots for visual regression
- Run Lighthouse for accessibility testing
- Profile performance during test runs
Testing Pyramid
- Unit Tests (Many): Fast, isolated, test single units
- Integration Tests (Some): Test component interactions
- E2E Tests (Few): Test complete user flows — use Chrome DevTools
Workflows
- Analyze: Use Glob and Grep to identify untested code
- Unit Tests: Cover all public functions
- Edge Cases: Test boundaries and error conditions
- Integration: Test external dependencies
- E2E: Use Chrome DevTools for browser automation
- Regression: Add test for each bug fix
Test Quality Standards
Deterministic
Tests must produce the same result every time.
Isolated
Tests should not depend on each other or shared state.
Clear
Test names should describe the behavior being tested.
Test Patterns
Arrange-Act-Assert (AAA) (Java + JUnit 5)
@ExtendWith(MockitoExtension.class)
class UserServiceTest {
@Mock
private EmailService emailService;
@InjectMocks
private UserService userService;
@Test
void registerUser_ValidEmail_SendsWelcomeEmail() {
// Arrange
String email = "test@example.com";
ArgumentCaptor<Email> emailCaptor = ArgumentCaptor.forClass(Email.class);
// Act
userService.register(email);
// Assert
verify(emailService).send(emailCaptor.capture());
Email sentEmail = emailCaptor.getValue();
assertThat(sentEmail.getTo()).isEqualTo("test@example.com");
assertThat(sentEmail.getSubject()).isEqualTo("Welcome!");
}
}
E2E Testing with Chrome DevTools
// Use Chrome DevTools MCP for browser automation
// - Navigate to pages
// - Fill forms and click buttons
// - Capture screenshots for visual regression
// - Run Lighthouse accessibility audits
// - Check console for errors
Commands (Java/Maven)
# Run unit tests
mvn test
# Run tests with coverage
mvn verify
# Run specific test class
mvn test -Dtest=UserServiceTest
# Run specific test method
mvn test -Dtest=UserServiceTest#registerUser_ValidEmail_SendsWelcomeEmail
# Generate coverage report
mvn jacoco:report
# View coverage report
open target/site/jacoco/index.html
Finding Untested Code
Use Glob and Grep to identify gaps:
- Use Glob to find all source files and test files
- Check which source files have corresponding test files
- Use Grep to see if functions are referenced in tests
Trustgrade B
- passBody integrity
Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.
- passType matchnot applicable to this artifact type
Whether the artifact is really the kind of thing its metadata claims it is.
- passFreshness
How long since the source repository was last pushed to.
- passPrompt injection
Scans the artifact's own text for instructions aimed at your agent rather than at you.
- warnLicenseno SPDX license detected
Whether the source repository declares an SPDX license permissive enough to redistribute.
How the grade is calculated
Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:
- Aevery check passed
- Bone warning
- Ctwo warnings
- Dprompt injection or body integrity failed, or three warnings
- Fone of those failed, and something else is wrong
These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.
Versions
git-b76c03b0af722026-07-31