AAD Quality Assurance & Compliance 3 — Questions and Answers
Question 1: Which assertion library is recommended for readable test assertions in AndroidX Test projects?
- Truth (Correct answer)
- Hamcrest
- AssertJ
- JUnit Assert
Correct answer: Truth
Google's Truth library provides fluent, readable assertions and is the recommended choice in AndroidX Test documentation.
Question 2: What does the `@Rule` annotation with `ActivityScenarioRule` provide in an Espresso test?
- Automatically launches and tears down an Activity for each test (Correct answer)
- Mocks the Activity lifecycle callbacks
- Disables animations for the test Activity
- Grants all runtime permissions before the test
Correct answer: Automatically launches and tears down an Activity for each test
`ActivityScenarioRule` launches the specified Activity before each test and cleans it up afterward.
Question 3: Which lint check category in Android enforces accessibility guidelines such as missing content descriptions?
- Accessibility (Correct answer)
- Correctness
- Performance
- Internationalization
Correct answer: Accessibility
Android Lint's Accessibility category flags issues like missing `contentDescription` on ImageViews.
Question 4: When writing a ViewModel unit test, what is the recommended way to handle `viewModelScope` coroutines synchronously?
- Use TestCoroutineDispatcher / UnconfinedTestDispatcher and replace Main dispatcher (Correct answer)
- Use Thread.sleep() to wait for coroutines
- Annotate the test with @Coroutine
- Use runBlocking from the production code
Correct answer: Use TestCoroutineDispatcher / UnconfinedTestDispatcher and replace Main dispatcher
Replacing `Dispatchers.Main` with a `TestDispatcher` lets tests control coroutine execution synchronously.
Question 5: Which Play Store policy requires that apps collecting personal data from children comply with?
- Children's Online Privacy Protection Act (COPPA) (Correct answer)
- General Data Protection Regulation (GDPR) only
- California Consumer Privacy Act (CCPA) only
- Health Insurance Portability and Accountability Act (HIPAA)
Correct answer: Children's Online Privacy Protection Act (COPPA)
Apps directed at children must comply with COPPA, which restricts collection of personal data from users under 13.
Question 6: What is the effect of calling `Mockito.verify(mock, times(2)).someMethod()` in a unit test?
- Asserts that someMethod was called exactly twice on the mock (Correct answer)
- Stubs someMethod to return a value twice
- Throws an exception if someMethod is called more than twice
- Verifies someMethod will be called in the future
Correct answer: Asserts that someMethod was called exactly twice on the mock
`verify` with `times(2)` fails the test if `someMethod` was not invoked exactly two times on the mock object.
Question 7: Which section of the Google Play Console requires developers to complete a questionnaire about data collected by their app?
- Data Safety (Correct answer)
- Content Rating
- App Content
- Privacy Policy
Correct answer: Data Safety
The Data Safety section requires developers to disclose what data the app collects, shares, and how it is handled.
Which assertion library is recommended for readable test assertions in AndroidX Test projects?