int (String[] args, String name, int count, boolean sendTree) { try { final Request request = JUnit4TestRunnerUtil.buildRequest(args, name, sendTree); if (request == null) return -2; final Runner testRunner = request.getRunner(); Description description = getDescription(request, testRunner); if (description == null) { return -2; } if (sendTree) { do { myTestsListener.sendTree(description); } while (--count > 0); } final JUnitCore runner = new JUnitCore(); runner.addListener(myTestsListener); for (String listener : myListeners) { final IDEAJUnitListener junitListener = Class.forName(listener).asSubclass(IDEAJUnitListener.class).getConstructor().newInstance(); runner.addListener(new MyCustomRunListenerWrapper(junitListener, description.getDisplayName())); } final Result result = runner.run(testRunner); return result.wasSuccessful() ? 0 : -1; } catch (Exception e) { e.printStackTrace(System.err); return -2; } }