Flutter

Unit Testing

test package, expect, matchers, mocking, mockito, test coverage, TDD principles

20 câu hỏi phỏng vấn·
Mid-Level
1

Which Dart package provides the core functionality for writing unit tests?

Câu trả lời

The test package is the official Dart package for writing unit tests. It provides test(), group(), setUp(), tearDown() functions and matchers for assertions. This package is included in dev_dependencies of any Flutter project and forms the foundation of all Dart testing.

2

Which function should be used to group multiple related tests into a logical suite?

Câu trả lời

The group() function allows grouping related tests together, improving organization and readability. Each group can have its own setUp and tearDown, and groups can be nested to create a test hierarchy. This improves the structure and maintenance of test suites.

3

When is the setUp() function executed in a group of tests?

Câu trả lời

setUp() is executed before each individual test in the group. This allows initializing the necessary state for each test, ensuring that each test starts in a clean and independent state. For a one-time initialization before all tests, use setUpAll() instead.

4

Which matcher should be used to verify that a value equals an expected value?

5

How to verify that an asynchronous function completes successfully in a test?

+17 câu hỏi phỏng vấn

Nắm vững Flutter cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí