🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.assertThat(repository).isEmpty()
  2. B.verify(repository, never()).deleteById(any())
  3. C.when(repository.deleteById(any())).thenThrow()
  4. 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 →