0
0
Fluttermobile~10 mins

Integration testing in Flutter - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Flutter integration test package.

Flutter
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/[1].dart';
Drag options to blanks, or click blank then click option'
Aintegration
Bintegration_test
Ctest_integration
Dintegration_test_flutter
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'flutter_test' instead of 'integration_test'.
Misspelling the package name.
2fill in blank
medium

Complete the code to initialize the integration test binding.

Flutter
void main() {
  final binding = [1].ensureInitialized();
}
Drag options to blanks, or click blank then click option'
AIntegrationTestWidgetsFlutterBinding
BFlutterBinding
CTestWidgetsFlutterBinding
DWidgetsFlutterBinding
Attempts:
3 left
💡 Hint
Common Mistakes
Using WidgetsFlutterBinding which is for unit/widget tests.
Forgetting to call ensureInitialized().
3fill in blank
hard

Fix the error in the test function declaration for integration testing.

Flutter
testWidgets('tap on button changes text', (WidgetTester [1]) async {
  // test code
});
Drag options to blanks, or click blank then click option'
Atest
Bcontext
Cwidget
Dtester
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'context' which is not a parameter here.
Using 'widget' or 'test' which are invalid parameter names.
4fill in blank
hard

Fill both blanks to pump the app and wait for animations to settle.

Flutter
await [1].pumpWidget(MyApp());
await [2].pumpAndSettle();
Drag options to blanks, or click blank then click option'
Atester
BwidgetTester
CtestController
DappTester
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for the same tester object.
Forgetting to await asynchronous calls.
5fill in blank
hard

Fill all three blanks to find a button by key, tap it, and verify text change.

Flutter
final button = find.byKey(const Key('[1]'));
await tester.tap(button);
await tester.[2]();
expect(find.text('[3]'), findsOneWidget);
Drag options to blanks, or click blank then click option'
Aincrement
BpumpAndSettle
CClicked!
Dsubmit
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong key strings that don't match the widget.
Forgetting to wait after tapping before checking text.
Expecting wrong text that doesn't appear after tap.