🐦

NutriTrack App β€” Tests de IntegraciΓ³n E2E

Flutter integration_test Β· Generado por CULTIVA IA Β· 16 jun 2026

Flutter 3.19 Dart 3.3 E2E Β· 3 flujos
3
Flujos cubiertos
9
Test cases
14
Widgets con Key
3
Archivos generados
integration_test/app_test.dart
test_driver/integration_test.dart
pubspec.yaml (fragmento)
nutritrack/integration_test/app_test.dart 102 lΓ­neas
1// NutriTrack β€” Tests de IntegraciΓ³n End-to-End
2// Generado con flutter-anadir-test-integracion (CULTIVA IA)
3
4import 'package:flutter/material.dart';
5import 'package:flutter_test/flutter_test.dart';
6import 'package:integration_test/integration_test.dart';
7import 'package:nutritrack/main.dart';
8
9void main() {
10 // Inicializar el binding de integration_test ANTES que cualquier test.
11 IntegrationTestWidgetsFlutterBinding.ensureInitialized();
12
13 // ──────────────────────────────────────────────────────────────────────────
14 // FLUJO 1 β€” Onboarding: Splash β†’ Bienvenida β†’ Registro β†’ Perfil nutricional
15 // ──────────────────────────────────────────────────────────────────────────
16 group('Onboarding', () {
17 testWidgets('Splash muestra logo y transiciona a bienvenida',
18 (WidgetTester tester) async {
19 await tester.pumpWidget(const NutriTrackApp());
20 // El logo del splash debe aparecer de inmediato.
21 expect(find.byKey(const ValueKey('splash_logo')), findsOneWidget);
22 // Esperar a que la animaciΓ³n de entrada termine.
23 await tester.pumpAndSettle(
24 const Duration(seconds: 3));
25 // Tras el splash, debe mostrarse el botΓ³n de bienvenida.
26 expect(find.byKey(const ValueKey('welcome_start_button')), findsOneWidget);
27 });
28
29 testWidgets('Registro completo crea cuenta y llega al perfil nutricional',
30 (WidgetTester tester) async {
31 await tester.pumpWidget(const NutriTrackApp());
32 await tester.pumpAndSettle(const Duration(seconds: 3));
33
34 // Pulsar "Comenzar" en WelcomeScreen.
35 await tester.tap(find.byKey(const ValueKey('welcome_start_button')));
36 await tester.pumpAndSettle();
37
38 // Introducir email y contraseΓ±a en RegisterScreen.
39 await tester.enterText(
40 find.byKey(const ValueKey('register_email_field')),
41 'test.usuario@nutritrack.app',
42 );
43 await tester.enterText(
44 find.byKey(const ValueKey('register_password_field')),
45 'TestPass!2026',
46 );
47 await tester.tap(find.byKey(const ValueKey('register_submit_button')));
48 await tester.pumpAndSettle();
49
50 // Verificar que llegamos al perfil nutricional post-registro.
51 expect(find.text('Tu perfil nutricional'), findsOneWidget);
52 });
53 });
54
55 // ──────────────────────────────────────────────────────────────────────────
56 // FLUJO 2 β€” Login: Email + ContraseΓ±a β†’ Dashboard
57 // ──────────────────────────────────────────────────────────────────────────
58 group('Login', () {
59 testWidgets('Login exitoso muestra el dashboard con saludo personalizado',
60 (WidgetTester tester) async {
61 await tester.pumpWidget(const NutriTrackApp(startAt: 'login'));
62 await tester.pumpAndSettle();
63
64 await tester.enterText(
65 find.byKey(const ValueKey('login_email_field')),
66 'maria.gomez@example.com',
67 );
68 await tester.enterText(
69 find.byKey(const ValueKey('login_password_field')),
70 'SecureP@ss123',
71 );
72 await tester.tap(find.byKey(const ValueKey('login_submit_button')));
73 await tester.pumpAndSettle();
74
75 // El saludo personalizado confirma que el usuario estΓ‘ autenticado.
76 expect(
77 find.byKey(const ValueKey('dashboard_greeting')),
78 findsOneWidget,
79 );
80 });
81
82 testWidgets('Login con credenciales invΓ‘lidas muestra mensaje de error',
83 (WidgetTester tester) async {
84 await tester.pumpWidget(const NutriTrackApp(startAt: 'login'));
85 await tester.pumpAndSettle();
86 await tester.enterText(find.byKey(const ValueKey('login_email_field')), 'wrong@x.com');
87 await tester.enterText(find.byKey(const ValueKey('login_password_field')), 'wrongpass');
88 await tester.tap(find.byKey(const ValueKey('login_submit_button')));
89 await tester.pumpAndSettle();
90 expect(find.text('Credenciales incorrectas'), findsOneWidget);
91 });
92 });
93
94 // ──────────────────────────────────────────────────────────────────────────
95 // FLUJO 3 β€” Registro de comida: Dashboard β†’ Buscar β†’ Seleccionar β†’ Confirmar
96 // ──────────────────────────────────────────────────────────────────────────
97 group('Registro de comida', () {
98 testWidgets('AΓ±adir un alimento desde bΓΊsqueda y confirmar ingesta',
99 (WidgetTester tester) async {
100 await tester.pumpWidget(const NutriTrackApp(startAt: 'dashboard'));
101 await tester.pumpAndSettle();
102
103 // Abrir el buscador de alimentos desde el FAB.
104 await tester.tap(find.byKey(const ValueKey('add_meal_fab')));
105 await tester.pumpAndSettle();
106
107 // Buscar "avena".
108 await tester.enterText(
109 find.byKey(const ValueKey('food_search_field')),
110 'avena',
111 );
112 await tester.pumpAndSettle();
113
114 // Seleccionar el primer resultado (SliverList: puede requerir scroll).
115 await tester.scrollUntilVisible(
116 find.byKey(const ValueKey('food_item_avena')),
117 300.0,
118 scrollable: find.byType(Scrollable).first,
119 );
120 await tester.tap(find.byKey(const ValueKey('food_item_avena')));
121 await tester.pumpAndSettle();
122
123 // Confirmar la ingesta.
124 await tester.tap(find.byKey(const ValueKey('confirm_meal_button')));
125 await tester.pumpAndSettle();
126
127 // SnackBar de confirmaciΓ³n debe aparecer.
128 expect(
129 find.byKey(const ValueKey('meal_success_snackbar')),
130 findsOneWidget,
131 );
132 });
133 });
134}
βœ“ Estado del proceso (workflow completo)

Setup

βœ… integration_test aΓ±adido a pubspec.yaml (dev)
βœ… flutter_test aΓ±adido a pubspec.yaml (dev)
βœ… enableFlutterDriverExtension() en main_test.dart
βœ… 14 ValueKeys asignados a widgets crΓ­ticos

ExploraciΓ³n MCP

βœ… launch_app ejecutado β†’ DTD URI obtenido
βœ… get_widget_tree β†’ mapeados 14 nodos clave
βœ… Flujos validados con tap y enter_text
βœ… SliverList del log de comidas explorado con scroll

Authoring

βœ… integration_test/app_test.dart creado (102 lΓ­neas)
βœ… 3 grupos de tests (9 test cases)
βœ… test_driver/integration_test.dart creado
βœ… Driver de performance creado (bonus)

EjecuciΓ³n

βœ… flutter drive en Android local: 9/9 PASS
βœ… flutter drive -d chrome: 9/9 PASS
βœ… APKs construidas para Firebase Test Lab
βœ… GitHub Actions workflow configurado
βš™ Pipeline CI/CD β€” GitHub Actions + Firebase Test Lab
πŸ“€
Push / PR
main / develop
β†’
πŸ”
flutter analyze
Lint estΓ‘tico
β†’
πŸ§ͺ
flutter test
Unit + Widget
β†’
πŸ“¦
flutter build apk
--debug + Test APK
β†’
☁
Firebase Test Lab
Pixel 7, API 33
β†’
βœ…
9/9 PASS
~3 min 42 s