Recall & Review
beginner
What is unit testing in Flutter?
Unit testing in Flutter means checking small parts of your app, like a single function, to make sure they work correctly by themselves.
Click to reveal answer
beginner
Which package is commonly used for writing unit tests in Flutter?
The
test package is used to write unit tests in Flutter. It provides tools to define and run tests.Click to reveal answer
beginner
What does the
test() function do in Flutter unit testing?The
test() function defines a single test case. You give it a description and a function that contains the code to check.Click to reveal answer
intermediate
Why should unit tests be fast and isolated?
Unit tests should be fast so you can run them often without waiting. They should be isolated to test only one thing at a time, avoiding side effects.
Click to reveal answer
beginner
What is the role of the
expect() function in Flutter unit tests?The
expect() function checks if a value matches what you expect. It compares actual results with expected results to pass or fail the test.Click to reveal answer
Which Flutter package is used to write unit tests?
✗ Incorrect
The 'test' package is the core package for writing unit tests in Flutter.
What does the
test() function require as arguments?✗ Incorrect
The 'test()' function needs a description and a function that contains the test code.
What is the purpose of the
expect() function?✗ Incorrect
The 'expect()' function compares actual and expected values to determine test success.
Why should unit tests be isolated?
✗ Incorrect
Isolation ensures tests do not affect each other and focus on a single unit.
Which of these is NOT a characteristic of good unit tests?
✗ Incorrect
Good unit tests should NOT depend on network calls to remain fast and reliable.
Explain how to write a simple unit test in Flutter using the test package.
Think about the basic structure: import, test definition, and checking results.
You got /4 concepts.
Why is it important to keep unit tests isolated and fast? Give an example.
Imagine testing a calculator function vs. testing a network call.
You got /3 concepts.