From 49fecac2972576fc2a5a24d1dd740f61eac8eb7f Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 1 May 2014 14:52:53 +0400 Subject: [PATCH] [git tests] Make sure other tear downs finish even if one fails --- .../git4idea/GitCucumberWorld.java | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java index d393d3d5b441..c3e0f6a3c374 100644 --- a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java +++ b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java @@ -50,6 +50,7 @@ import org.junit.Assert; import org.picocontainer.MutablePicoContainer; import java.io.File; +import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -180,17 +181,39 @@ public class GitCucumberWorld { } @After("@remote") - @Order(1) + @Order(5) public void tearDownRemoteOperations() { } @After - public void tearDown(@NotNull ScenarioResult result) throws Throwable { - waitForPendingTasks(); - nullifyStaticFields(); + @Order(4) + public void waitForPendingTasks() throws InterruptedException, ExecutionException, TimeoutException { + for (Future future : myAsyncTasks) { + future.get(30, TimeUnit.SECONDS); + } + } + + @After + @Order(3) + public void cleanupWorld() throws IllegalAccessException { + for (Field field : GitCucumberWorld.class.getDeclaredFields()) { + if (Modifier.isStatic(field.getModifiers())) { + field.set(null, null); + } + } + } + + @After + @Order(2) + public void dumpToLog(@NotNull ScenarioResult result) throws IOException { if (result.isFailed()) { TestLoggerFactory.dumpLogToStdout(getStartTestMarker()); } + } + + @After + @Order(1) + public void tearDownFixture() throws Exception { edt(new ThrowableRunnable() { @Override public void run() throws Exception { @@ -203,20 +226,6 @@ public class GitCucumberWorld { myAsyncTasks.add(ApplicationManager.getApplication().executeOnPooledThread(runnable)); } - private static void waitForPendingTasks() throws InterruptedException, ExecutionException, TimeoutException { - for (Future future : myAsyncTasks) { - future.get(30, TimeUnit.SECONDS); - } - } - - private static void nullifyStaticFields() throws IllegalAccessException { - for (Field field : GitCucumberWorld.class.getDeclaredFields()) { - if (Modifier.isStatic(field.getModifiers())) { - field.set(null, null); - } - } - } - @SuppressWarnings("unchecked") private static T overrideService(@NotNull Project project, Class serviceInterface, Class serviceImplementation) { String key = serviceInterface.getName();