Skip to content

Commit

Permalink
Rhino: Simplify test. Make sure it fails is nothing is thrown.
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Sep 12, 2013
1 parent 47a8510 commit b0496b3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions rhino/src/test/java/cucumber/runtime/rhino/RhinoHooksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
import static org.mockito.Mockito.doNothing;
import gherkin.formatter.model.Tag;

Expand All @@ -24,6 +22,7 @@
import cucumber.runtime.RuntimeGlue;
import cucumber.runtime.io.ClasspathResourceLoader;
import cucumber.runtime.io.ResourceLoader;
import org.mozilla.javascript.WrappedException;

@RunWith(MockitoJUnitRunner.class)
public class RhinoHooksTest {
Expand Down Expand Up @@ -70,7 +69,7 @@ public void shouldCallAddBeforeAndAfterHook() throws IOException {
assertHooks(beforeHooks.get(5), afterHooks.get(5), TAGS, 20, 600);
}

@Test
@Test(expected = InterruptedException.class)
public void shouldFailWithTimeout() throws Throwable {
// when
RhinoBackend jsBackend = new RhinoBackend(resourceLoader);
Expand All @@ -79,13 +78,10 @@ public void shouldFailWithTimeout() throws Throwable {

try {
beforeHooks.get(0).execute(null);
} catch (Exception e) {
// then
assertThat(e.getCause(), instanceOf(InterruptedException.class));
return;
fail();
} catch(WrappedException expected) {
throw expected.getWrappedException();
}

fail(InterruptedException.class.getSimpleName() + " expected");
}

private void assertHooks(HookDefinition beforeHook, HookDefinition afterHook, String[] tags, int order, long timeoutMillis) {
Expand Down

0 comments on commit b0496b3

Please sign in to comment.