diff --git a/src/test/java/io/fabric8/maven/docker/service/RunServiceTest.java b/src/test/java/io/fabric8/maven/docker/service/RunServiceTest.java index d3a7afb9d..28187bf8c 100644 --- a/src/test/java/io/fabric8/maven/docker/service/RunServiceTest.java +++ b/src/test/java/io/fabric8/maven/docker/service/RunServiceTest.java @@ -44,6 +44,7 @@ import mockit.Mocked; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -303,12 +304,8 @@ public void testWithMultipleStopExceptions() throws Exception { runService = new RunService(docker, queryService, tracker, logOutputSpecFactory, log); - try { - runService.stopStartedContainers(false, true, true, testLabel); - fail("Should have thrown exception"); - } catch (DockerAccessException | ExecException e) { - assertEquals(e.getLocalizedMessage(), "(TEST two,TEST one)"); - } + Exception thrownException = assertThrows(DockerAccessException.class, () -> runService.stopStartedContainers(false, true, true, testLabel)); + assertEquals("(TEST two,TEST one)", thrownException.getLocalizedMessage()); } @Test