79519390

Date: 2025-03-19 07:08:47
Score: 1
Natty:
Report link

Ik this is late but for the 2nd part of your question, you can add the

objectFactory.close();
contextMock.close();

in the @AfterAll or @AfterEach method which tears down the test

@AfterEach
public void teardown() {
  objectFactory.close();
  contextMock.close();
}

This will ensure even if an exception occurs, the mocks are closed or de-registered properly.

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @AfterAll
  • User mentioned (0): @AfterEach
  • Low reputation (0.5):
Posted by: trojanMorse