gabor7d2 / DesertSabotage

Uni homework for Integration and Verification Techniques
0 stars 0 forks source link

Static mock not closed in ControllerActionsTest.spawnPipe #23

Closed gabor7d2 closed 3 months ago

gabor7d2 commented 3 months ago

The static mock (ModelObjectFactory) has to be closed after mocking, so that it doesn't persist between tests.

One of my tests fails when your test also runs, so please urgently fix this issue, I cannot merge my tests until you fix this.

I recommend this way:

try (MockedStatic<ModelObjectFactory> mock = mockStatic(ModelObjectFactory.class)) {
    mock.when(ModelObjectFactory::cisternCreatePipe).thenReturn(createdPipe);
    cistern.spawnPipe();
}