Android

Android Testing Advanced

Advanced Android testing: TDD, mocking, Coroutines, Flow, Compose UI, and test coverage

18 คำถามสัมภาษณ์·
Senior
1

How do Mock, Stub, and Fake differ in tests?

คำตอบ

A Mock verifies interactions (who calls what, how many times, with which arguments). A Stub returns predefined responses without verification. A Fake is a simplified working implementation (e.g., in‑memory repository). Mocks emphasize behavior verification, Stubs support state verification, and Fakes provide lightweight realistic alternatives.

2

How to use MockK for mocking in Kotlin?

คำตอบ

MockK is Kotlin‑centric: mockk<T>() creates a double, every { ... } returns ... stubs responses, verify { ... } checks interactions. It supports coroutines (coEvery/coVerify), relaxed mocks, and argument capture via slot.

3

What is TDD (Test-Driven Development)?

คำตอบ

TDD means writing a test before the code and iterating Red‑Green‑Refactor: failing test, minimal code to pass, then refactor without changing behavior. Benefits: better coverage, more testable design, living documentation.

4

How to test Coroutines with runTest?

5

How to test Flow?

+15 คำถามสัมภาษณ์

เชี่ยวชาญ Android สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี