int (String[] args, String programParam, int count, boolean sendTree) { try { JUnit5TestExecutionListener listener = myExecutionListeners.get(0); listener.initializeIdSuffix(!sendTree); final String[] packageNameRef = new String[1]; final LauncherDiscoveryRequest discoveryRequest = JUnit5TestRunnerUtil.buildRequest(args, packageNameRef, programParam); List<TestExecutionListener> listeners = new ArrayList<>(); listeners.add(listener); for (String listenerClassName : myListeners) { final IDEAJUnitListener junitListener = (IDEAJUnitListener)Class.forName(listenerClassName).newInstance(); listeners.add(new MyCustomListenerWrapper(junitListener)); } if (sendTree) { for (JUnit5TestExecutionListener executionListener : myExecutionListeners) { executionListener.setRootName(packageNameRef[0]); executionListener.setSendTree(); } } myLauncher.execute(discoveryRequest, listeners.toArray(new TestExecutionListener[0])); return listener.wasSuccessful() ? 0 : -1; } catch (Exception e) { System.err.println("Internal Error occurred."); e.printStackTrace(System.err); return -2; } finally { if (count > 0) myExecutionListeners.remove(0); } }