public RunResult invoke()

in surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java [117:166]


    public RunResult invoke(Object forkTestSet) throws TestSetFailedException {
        upgradeCheck();

        ReporterFactory reporterFactory = providerParameters.getReporterFactory();

        RunResult runResult;
        try {
            TestReportListener<TestOutputReportEntry> reporter = reporterFactory.createTestReportListener();
            JUnit4RunListener listener = new JUnit4RunListener(reporter);
            listener.setRunMode(NORMAL_RUN);

            startCapture(listener);
            // startCapture() called in prior to setTestsToRun()

            if (testsToRun == null) {
                setTestsToRun(forkTestSet);
            }

            Notifier notifier = new Notifier(listener, getSkipAfterFailureCount());
            Result result = new Result();
            notifier.addListeners(createCustomListeners(customRunListeners)).addListener(result.createListener());

            if (isFailFast() && commandsReader != null) {
                registerPleaseStopJUnitListener(notifier);
            }

            try {
                notifier.fireTestRunStarted(
                        testsToRun.allowEagerReading()
                                ? createTestsDescription(testsToRun)
                                : createDescription(UNDETERMINED_TESTS_DESCRIPTION));

                if (commandsReader != null) {
                    registerShutdownListener(testsToRun);
                    commandsReader.awaitStarted();
                }

                for (Class<?> testToRun : testsToRun) {
                    executeTestSet(testToRun, reporter, notifier, listener);
                }
            } finally {
                notifier.fireTestRunFinished(result);
                notifier.removeListeners();
            }
            rethrowAnyTestMechanismFailures(result);
        } finally {
            runResult = reporterFactory.close();
        }
        return runResult;
    }