Skip to content

Instantly share code, notes, and snippets.

@MahdiGharooni
Created September 14, 2022 06:10
Show Gist options
  • Save MahdiGharooni/f74b421c5c6a569732e41f7ec290fbb8 to your computer and use it in GitHub Desktop.
Save MahdiGharooni/f74b421c5c6a569732e41f7ec290fbb8 to your computer and use it in GitHub Desktop.
Flutter Integration Test
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:sun/blocs/sun_bloc_provider.dart';
import 'package:sun/helpers/strings.dart';
import 'package:sun/pages/account_inquiry/account_inquiry_page.dart';
import '../../test/test_settings.dart';
void main() {
testWidgets('Iban TextFormField', (WidgetTester tester) async {
/// init
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
TestSettings.setAuthentication();
await tester.pumpWidget(MultiBlocProvider(
providers: SunBlocProvider.getProviders(),
child: MaterialApp(home: (IntegrationTestPage())),
));
await tester.pumpAndSettle();
/// execute
final ibanTextFormField =
find.byKey(ValueKey('IntegrationTestTextFormField')).first;
await tester.enterText(ibanTextFormField, '123456789123');
final ibanToAccountButton =
find.byKey(ValueKey('IntegrationTestButton')).first;
await tester.tap(ibanToAccountButton);
await tester.pumpAndSettle(Duration(seconds: 3));
/// check outputs
final errorMessage = find.text(IBAN_IS_INCORRECT);
await tester.pumpAndSettle(Duration(seconds: 3));
expect(
errorMessage,
findsOneWidget,
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment