Class JUnitCore


  • public class JUnitCore
    extends Object
    Class for accessing JUnit support; all functionality is provided by static methods.

    This class is not intended to be subclassed or instantiated by clients.

    Since:
    2.1
    Restriction:
    This class is not intended to be subclassed by clients.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Constructor Detail

      • JUnitCore

        public JUnitCore()
    • Method Detail

      • addTestRunListener

        public static void addTestRunListener​(TestRunListener listener)
        Adds a listener for test runs.

        Note: If your plug-in should be loaded when a test run starts, please contribute to the org.eclipse.jdt.junit.testRunListeners extension point instead.

        Parameters:
        listener - the listener to be added
        Since:
        3.3
      • removeTestRunListener

        public static void removeTestRunListener​(TestRunListener listener)
        Removes a listener for test runs.
        Parameters:
        listener - the listener to be removed
        Since:
        3.3
      • findTestTypes

        public static IType[] findTestTypes​(IJavaElement container,
                                            IProgressMonitor monitor)
                                     throws CoreException,
                                            OperationCanceledException
        Finds types that contain JUnit tests in the given container.
        Parameters:
        container - the container
        monitor - the progress monitor used to report progress and request cancelation, or null if none
        Returns:
        test types inside the given container
        Throws:
        CoreException - when a problem occurs while accessing container or its children
        OperationCanceledException - if the operation has been canceled
        Since:
        3.5
      • exportTestRunSession

        public static void exportTestRunSession​(ITestRunSession testRunSession,
                                                File file)
                                         throws CoreException
        Exports the given test run session into an XML report file.
        Parameters:
        testRunSession - the test run session
        file - the destination
        Throws:
        CoreException - if an error occurred
        Since:
        3.7
      • exportTestRunSession

        public static void exportTestRunSession​(ITestRunSession testRunSession,
                                                OutputStream output)
                                         throws CoreException
        Exports the given test run session to an output stream.
        Parameters:
        testRunSession - the test run session
        output - the output stream
        Throws:
        CoreException - if an error occurred
        Since:
        3.7
      • importTestRunSession

        public static ITestRunSession importTestRunSession​(File file)
                                                    throws CoreException
        Imports a test run session from the given file.
        Parameters:
        file - a file containing a test run session transcript
        Returns:
        the imported test run session
        Throws:
        CoreException - if the import failed
        Since:
        3.7
      • importTestRunSession

        public static ITestRunSession importTestRunSession​(String url,
                                                           IProgressMonitor monitor)
                                                    throws CoreException
        Imports a test run session from the given URL.
        Parameters:
        url - an URL to a test run session transcript
        monitor - a progress monitor for cancellation
        Returns:
        the imported test run session, or null if the import has been cancelled
        Throws:
        CoreException - if the import failed
        Since:
        3.7