testing
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
More from nguyenhuuca/assessment
requirements-analysis
Analyze and refine product requirements. Use when clarifying scope, identifying gaps, or validating requirements. Covers requirement types and analysis techniques.
16security-review
Conduct security code reviews. Use when reviewing code for vulnerabilities, assessing security posture, or auditing applications. Covers security review checklist.
13identity-access
Implement identity and access management. Use when designing authentication, authorization, or user management. Covers OAuth2, OIDC, and RBAC.
12execution-roadmaps
Create execution roadmaps for projects. Use when planning multi-phase projects or feature rollouts. Covers phased delivery and milestone planning.
12cloud-native-patterns
Apply cloud-native architecture patterns. Use when designing for scalability, resilience, or cloud deployment. Covers microservices, containers, and distributed systems.
12writing-pr-faqs
Write Press Release / FAQ documents. Use when proposing new products or features using Amazon's working backwards method. Covers PR/FAQ format.
11