Testing I Quiz :Engineering Maintainable Android Apps (Android App Development Specialization) Answers 2025
Question 1 – Reasons to write tests
✔️ to help make sure that changes to code do not break existing functionality
❌ to make apps run faster by reducing binary sizes
❌ to measure how effective developers are
✔️ to ensure that new functionality operates as expected
Question 2 – True when building a new app
✔️ Finding the right design may be iterative
❌ There is exactly one way to implement it
✔️ Measuring the impact of changes is critical
❌ There is exactly one way to design it
Question 3 – What is a unit test
❌ a test that isolates multiple components
❌ a test of a single UI element
❌ a test that measures performance
❌ a measurement of test coverage
✔️ a test that isolates a specific component
Question 4 – Java framework used for unit tests
❌ Dagger
❌ Retrofit
❌ Apache Commons
✔️ JUnit
❌ Android
Question 5 – Why unit tests should run quickly
✔️ minimize the time developers wait for feedback
❌ avoid blocking the main thread
❌ minimize startup time of emulator
❌ ensure UI components are not slowed down
✔️ minimize mistakes that developers make
Question 6 – Valid JUnit tests
❌ @Unit public void ensureTrue() { assertEquals(true,true); }
❌ @Test public void test() { ensure.that(true); }
❌ @Unit public void test() throws Exception { assert(true == true); }
❌ public void test() { ensureTrue(true); }
✔️ @Test public void ensureTrue() { assertEquals(true,true); }
Question 7 – NOT appropriate ways to set up MyObject
The question asks which are NOT appropriate.
❌ (NOT appropriate) Option 1 – initializing inside each test
✔️ (Appropriate) Option 2 – inline initialization
✔️ (Appropriate) Option 3 – using @Before
✔️ (Appropriate) Option 4 – using @Before
❌ (NOT appropriate) Option 5 – inline initialization but missing second test
Correct NOT appropriate answers:
✔️ Option 1
✔️ Option 5
Question 8 – Valid ways to test dangerous() throwing checked exception
❌ assert without handling exception
✔️ try/catch with assert inside
❌ using @Unit (invalid annotation)
✔️ @Test with throws Exception
✔️ try/catch and ignore exception
Question 9 – Valid uses of code coverage
❌ techniques to help test faster
❌ guarantee app is bug free
✔️ determine where more testing needed
❌ evaluate quality of dev team
✔️ determine if app has been tested sufficiently
Question 10 – What is true about MyObject constructor
Given:
private MyObject myObject = new MyObject();
✔️ Constructor is called at least once per @Test (because test classes recreate instances per test)
❌ Called only once before first test
❌ Called only once before second test
❌ Constructor not called → NPE
❌ @Before needed
Correct answer:
✔️ The MyObject constructor will be called at least once for each @Test annotation in the class.
📊 Summary Table
| Q | Correct Options |
|---|---|
| 1 | A, D |
| 2 | A, C |
| 3 | E |
| 4 | D |
| 5 | A, E |
| 6 | E |
| 7 | 1, 5 |
| 8 | B, D, E |
| 9 | C, E |
| 10 | A |