0
0
Fluttermobile~10 mins

Why testing ensures app reliability in Flutter - Test Your Understanding

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

Complete the code to create a simple test that checks if the app title is correct.

Flutter
testWidgets('App has correct title', (WidgetTester tester) async {
  await tester.pumpWidget(MyApp());
  expect(find.text([1]), findsOneWidget);
});
Drag options to blanks, or click blank then click option'
A'My App'
B'Hello World'
C'Flutter Demo Home Page'
D'Test App'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong title string that does not match the app's title.
Forgetting to wrap the title in quotes.
2fill in blank
medium

Complete the code to pump the widget and trigger a frame in the test.

Flutter
await tester.[1](MyApp());
Drag options to blanks, or click blank then click option'
ApumpWidget
BstartWidget
CrenderWidget
DbuildWidget
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like buildWidget or renderWidget.
Confusing pumpWidget with other test methods.
3fill in blank
hard

Fix the error in the test assertion to check if a button with text 'Click Me' exists.

Flutter
expect(find.text([1]), findsOneWidget);
Drag options to blanks, or click blank then click option'
A'Click Me'
B'Tap Here'
C'Press Me'
D'Submit'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different button text than the one in the app.
Forgetting to put the text inside quotes.
4fill in blank
hard

Fill both blanks to write a test that taps a button and verifies a counter increments.

Flutter
await tester.tap(find.text([1]));
await tester.[2]();
Drag options to blanks, or click blank then click option'
A'Increment'
Bpump
CpumpWidget
D'Decrement'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong button label like 'Decrement'.
Calling pumpWidget instead of pump after tap.
5fill in blank
hard

Fill all three blanks to write a test that verifies the counter text updates after tapping.

Flutter
expect(find.text('[1]'), findsOneWidget);
await tester.tap(find.byIcon([2]));
await tester.[3]();
Drag options to blanks, or click blank then click option'
A0
BIcons.add
Cpump
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong initial counter value.
Using the wrong icon or forgetting to call pump().