← Quiz: Testing Spring Boot: all 10 questions
Quiz: Testing Spring Boot · Question 3 of 10
How do you check that deleteById was NOT called?
How do you check that deleteById was NOT called?
- A.assertThat(repository).isEmpty()
- B.verify(repository, never()).deleteById(any())
- C.when(repository.deleteById(any())).thenThrow()
- D.@Test(expected = NeverCalled.class)
Answer & explanation
Correct answer: verify(repository, never()).deleteById(any())
verify with never() checks the interaction didn't happen.
Can you get the rest right without peeking?
Take the timed Quiz: Testing Spring Boot quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →