Android Testing
JUnit, Espresso, unit tests, instrumented tests, assertions
1What is JUnit?
What is JUnit?
Câu trả lời
JUnit is a unit testing framework for Java and Kotlin. It's the standard for writing and executing automated tests. JUnit 4 uses annotations (@Test, @Before, @After) to define tests and their lifecycle. JUnit tests are fast because they run on the local JVM without Android emulator.
2What is the @Test annotation used for?
What is the @Test annotation used for?
Câu trả lời
@Test marks a method as a unit test. The method will be executed by the test runner. Without @Test, the method is ignored. Example: @Test fun testAddition() { assertEquals(4, 2 + 2) }. Each @Test must be independent and not depend on execution order.
3What is the @Before annotation used for?
What is the @Before annotation used for?
Câu trả lời
@Before marks a method that executes BEFORE each test (@Test). Useful for initializing common objects, creating mocks, resetting state. Example: @Before fun setUp() { viewModel = MyViewModel() }. If you have 5 tests, @Before runs 5 times. Alternative: @BeforeClass for single execution before all tests.
What is the @After annotation used for?
What is an assertion in testing?
+25 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Android khác
Android Fundamentals
Android UI and Resources
Android Lifecycle
Android Navigation
Android Data Management
Android Networking
Android Gradle
Kotlin Language Essentials for Android
Room Database
Background Work
Jetpack Compose
Permissions and Device Features
Firebase for Android
Android MVVM Architecture
Advanced Android Networking
Kotlin Collections and Operators
Kotlin Coroutines and Flow
Android Dependency Injection
Android MVI Architecture
Android Clean Architecture
Android Compose Advanced
Android Performance and Monitoring
Android Security and Privacy
Android CI/CD and Release
Android UX and Form Factors
Android Testing Advanced
Nắm vững Android 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í