Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
- Unit testing: test one unit (method/class) in isolation, written by developers, run automatically and often.
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
- JUnit: a framework for writing repeatable automated Java tests; a test method is annotated @Test and returns void.
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
- Verdicts: pass, fail (assertion failed), error (unexpected exception).
Exam weight Low
Exam weight Low
- Assertions: Boolean checks that make the test fail if they are false.
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight High
- assertEquals(expected, actual), assertTrue, assertFalse, assertNull, assertNotNull, assertSame (same reference), assertArrayEquals.
Exam trapassertEquals uses equals(); assertSame checks the two references are the SAME object.
🎯 How this can come up · 1 question
MCQ
Which assertion checks that two references point to the same object?
Correct: assertSame.
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
- Floating point: assertEquals(expected, actual, delta), e.g. assertEquals(0.3, 0.1 + 0.2, 0.0001).
Exam weight Low
Exam weight High
- Expected exceptions: assertThrows(IllegalArgumentException.class, () -> obj.method(-1));
🎯 How this can come up · 1 question
MCQ
JUnit 5 checks that code throws an exception with:
Correct: assertThrows.
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
- Each test must be independent of the others (no shared mutable state, any order).
Exam weight Low
Exam weight High
- @BeforeEach / @AfterEach run before/after EVERY test; @BeforeAll / @AfterAll run once per class and must be static.
🎯 How this can come up · 1 question
MCQ
Setup code that must run once before all tests in the class uses:
Correct: @BeforeAll (static).
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
Exam weight Low
- @RepeatedTest(n) runs a test n times.
Exam weight Low
No slides match this filter.
































































