int (final String[] argv, final ClassLoader classLoader) { final Ref<Throwable> errorRef = new Ref<>(); final Ref<Runtime> runtimeRef = new Ref<>(); try { UITestUtil.replaceIdeEventQueueSafely(); EdtInvocationManager.invokeAndWaitIfNeeded(() -> { IdeEventQueue.getInstance().getRwLockHolder().runWriteIntentReadAction(() -> { try { RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<>(Arrays.asList(argv))); MultiLoader resourceLoader = new MultiLoader(classLoader) { @Override public Iterable<Resource> resources(String path, String suffix) { Iterable<Resource> resources = super.resources(path, suffix); if (!TestCaseLoader.shouldBucketTests() || !".feature".equals(suffix)) { return resources; } List<Resource> result = new ArrayList<>(); for (Resource resource : resources) { if (TestCaseLoader.matchesCurrentBucket(resource.getPath())) { result.add(resource); } } return result; } }; ResourceLoaderClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); runtimeRef.set(runtime); runtime.run(); } catch (Throwable throwable) { errorRef.set(throwable); Logger.getInstance(CucumberMain.class).error(throwable); } return null; }); }); } catch (Throwable t) { errorRef.set(t); Logger.getInstance(CucumberMain.class).error(t); } final Throwable throwable = errorRef.get(); if (throwable != null) { LOG.error(throwable); } for (Throwable error : runtimeRef.get().getErrors()) { LOG.error(error); } return throwable != null ? 1 : 0; }