0
0
Fluttermobile~5 mins

Unit testing in Flutter - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Atest
Bflutter_test
Chttp
Dprovider
What does the test() function require as arguments?
AA description string and a callback function
BOnly a callback function
COnly a description string
DA widget and a callback function
What is the purpose of the expect() function?
ATo run the test
BTo define a test group
CTo check if a value matches the expected result
DTo mock dependencies
Why should unit tests be isolated?
ATo test multiple features at once
BTo avoid side effects and test only one thing
CTo slow down the testing process
DTo depend on external services
Which of these is NOT a characteristic of good unit tests?
AFast execution
BIsolated from other tests
CRepeatable with same results
DDependent on network calls
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.