Skip to content

Commit

Permalink
add regression test for testcontainers#335
Browse files Browse the repository at this point in the history
  • Loading branch information
tbcs committed May 4, 2017
1 parent 729face commit 9f720a5
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.testcontainers.containers;

import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

public class FailureDetectingExternalResourceTest {

@Test
public void finishedIsCalledForCleanupIfStartingThrows() throws Throwable {
FailureDetectingExternalResource res = spy(FailureDetectingExternalResource.class);
Statement stmt = res.apply(mock(Statement.class), Description.EMPTY);
doThrow(new RuntimeException()).when(res).starting(any());
try {
stmt.evaluate();
} catch (Throwable t) {
// ignore
}
verify(res).starting(any());
verify(res).finished(any());
}

}

0 comments on commit 9f720a5

Please sign in to comment.