D. Missing @Test annotation on testIsNotEmpty method
Solution
Step 1: Check annotations on test methods
testIsEmpty has @Test annotation, but testIsNotEmpty does not, so it won't run as a test.
Step 2: Understand impact of missing annotation
Without @Test, testIsNotEmpty is ignored during test execution, missing coverage.
Final Answer:
Missing @Test annotation on testIsNotEmpty method -> Option D
Quick Check:
All test methods need @Test [OK]
Hint: Every test method must have @Test annotation [OK]
Common Mistakes:
Forgetting @Test annotation on test methods
Thinking test methods must be static
Confusing assertion methods with annotations
5. You have a test class with multiple test methods for a UserService. You want to organize tests by feature (e.g., login, registration) within the same class. Which is the best practice to keep the test class organized and maintainable?
hard
A. Group test methods by feature using nested classes or clear method name prefixes
B. Put all tests in one method to reduce class size
C. Create separate test classes for each feature without grouping
D. Use random order of test methods to avoid bias
Solution
Step 1: Consider organization within a test class
Grouping related tests by feature improves readability and helps maintain tests logically.
Step 2: Use nested classes or naming conventions
Nested classes or method name prefixes (e.g., loginTest_*, registrationTest_*) clearly separate features inside one test class.
Final Answer:
Group test methods by feature using nested classes or clear method name prefixes -> Option A
Quick Check:
Organize tests by feature inside class [OK]
Hint: Use nested classes or prefixes to group feature tests [OK]
Common Mistakes:
Putting all tests in one method reduces clarity
Creating too many small classes without grouping
Ignoring logical grouping harms maintainability
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.