skills/testing/SKILL.md
1600+ lines of testing mastery - unit tests, widget tests, integration tests, E2E, coverage, mocking with production-ready code examples.
npx skillsauth add pluginagentmarketplace/custom-plugin-flutter custom-plugin-flutter-skill-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
// Unit test
void main() {
group('Calculator', () {
late Calculator calc;
setUp(() {
calc = Calculator();
});
test('add returns sum', () {
expect(calc.add(2, 3), equals(5));
});
});
}
// Widget test
void main() {
testWidgets('Counter increments', (tester) async {
await tester.pumpWidget(const MyApp());
expect(find.text('0'), findsOneWidget);
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
expect(find.text('1'), findsOneWidget);
});
}
// Integration test
void main() {
group('User Flow', () {
testWidgets('Complete user journey', (tester) async {
await tester.pumpWidget(const MyApp());
await tester.tap(find.text('Login'));
await tester.pumpAndSettle();
expect(find.text('Welcome'), findsOneWidget);
});
});
}
class UserService {
Future<User> getUser(String id) async {
// Implementation
}
}
void main() {
group('UserService', () {
late UserService service;
late MockUserRepository mockRepository;
setUp(() {
mockRepository = MockUserRepository();
service = UserService(mockRepository);
});
test('getUser returns user', () async {
final user = User(id: '1', name: 'John');
when(mockRepository.getUser('1')).thenAnswer((_) async => user);
final result = await service.getUser('1');
expect(result, user);
verify(mockRepository.getUser('1')).called(1);
});
test('getUser throws on error', () async {
when(mockRepository.getUser('1'))
.thenThrow(Exception('Not found'));
expect(
() => service.getUser('1'),
throwsException,
);
});
});
}
void main() {
testWidgets('Render user card', (tester) async {
const user = User(id: '1', name: 'John Doe', email: '[email protected]');
await tester.pumpWidget(
MaterialApp(home: Scaffold(body: UserCard(user: user))),
);
expect(find.text('John Doe'), findsOneWidget);
expect(find.text('[email protected]'), findsOneWidget);
});
testWidgets('Tap user card navigates', (tester) async {
const user = User(id: '1', name: 'John Doe', email: '[email protected]');
await tester.pumpWidget(MaterialApp(home: Scaffold(body: UserCard(user: user))));
await tester.tap(find.byType(UserCard));
await tester.pumpAndSettle();
expect(find.byType(UserDetailPage), findsOneWidget);
});
}
class MockUserRepository extends Mock implements UserRepository {}
final mockRepository = MockUserRepository();
// Setup mock behavior
when(mockRepository.getUser('1')).thenAnswer((_) async => User(...));
// Verify calls
verify(mockRepository.getUser('1')).called(1);
// Capture arguments
final captured = verify(mockRepository.updateUser(captureAny)).captured;
void main() {
group('User Creation Flow', () {
testWidgets('Create user and verify', (tester) async {
await tester.pumpWidget(const MyApp());
// Navigate to create user
await tester.tap(find.text('Add User'));
await tester.pumpAndSettle();
// Fill form
await tester.enterText(find.byKey(Key('nameField')), 'John');
await tester.enterText(find.byKey(Key('emailField')), '[email protected]');
// Submit
await tester.tap(find.text('Create'));
await tester.pumpAndSettle();
// Verify result
expect(find.text('User created'), findsOneWidget);
});
});
}
Ensure bulletproof quality with comprehensive testing.
tools
2300+ lines of state management mastery - all patterns (Provider, Riverpod, BLoC, GetX), dependency injection, persistence, testing with production-ready code examples.
tools
Production-grade Flutter plugin development mastery - Platform channels, federated architecture, MethodChannel/EventChannel, iOS Swift/Android Kotlin integration, pub.dev publishing with comprehensive code examples
tools
1600+ lines of performance optimization mastery - profiling, rendering, memory, network, battery, APK size with production-ready code examples.
tools
Production-grade Flutter navigation mastery - Navigator 2.0, GoRouter, deep linking, nested navigation, route guards, web URL handling with comprehensive code examples