Class JUnitLaunchShortcut

java.lang.Object
org.eclipse.jdt.junit.launcher.JUnitLaunchShortcut
All Implemented Interfaces:
org.eclipse.debug.ui.ILaunchShortcut, org.eclipse.debug.ui.ILaunchShortcut2

public class JUnitLaunchShortcut extends Object implements org.eclipse.debug.ui.ILaunchShortcut2
The launch shortcut to launch JUnit tests.

This class may be instantiated and subclassed.

Since:
3.3
  • Constructor Details

    • JUnitLaunchShortcut

      public JUnitLaunchShortcut()
      Default constructor.
  • Method Details

    • launch

      public void launch(org.eclipse.ui.IEditorPart editor, String mode)
      Specified by:
      launch in interface org.eclipse.debug.ui.ILaunchShortcut
    • launch

      public void launch(org.eclipse.jface.viewers.ISelection selection, String mode)
      Specified by:
      launch in interface org.eclipse.debug.ui.ILaunchShortcut
    • getLaunchConfigurationTypeId

      protected String getLaunchConfigurationTypeId()
      Returns the launch configuration type id of the launch configuration this shortcut will create. Clients can override this method to return the id of their launch configuration.
      Returns:
      the launch configuration type id of the launch configuration this shortcut will create
    • createLaunchConfiguration

      protected org.eclipse.debug.core.ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element) throws org.eclipse.core.runtime.CoreException
      Creates a launch configuration working copy for the given element. The launch configuration type created will be of the type returned by getLaunchConfigurationTypeId(). The element type can only be of type IJavaProject, IPackageFragmentRoot, IPackageFragment, IType or IMethod.

      Clients can extend this method (should call super) to configure additional attributes on the launch configuration working copy. Note that this method calls createLaunchConfiguration(element, null). Extenders are recommended to extend the two-args method instead of this method.

      Parameters:
      element - element to launch
      Returns:
      a launch configuration working copy for the given element
      Throws:
      org.eclipse.core.runtime.CoreException - if creation failed
    • createLaunchConfiguration

      protected org.eclipse.debug.core.ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element, String testName) throws org.eclipse.core.runtime.CoreException
      Creates a launch configuration working copy for the given element. The launch configuration type created will be of the type returned by getLaunchConfigurationTypeId(). The element type can only be of type IJavaProject, IPackageFragmentRoot, IPackageFragment, IType or IMethod.

      Clients can extend this method (should call super) to configure additional attributes on the launch configuration working copy.

      Parameters:
      element - element to launch
      testName - name of the test to launch, e.g. the method name or an artificial name created by a JUnit runner, or null if none. The testName is ignored if the element is an IMethod; the method name is used in that case.
      Returns:
      a launch configuration working copy for the given element
      Throws:
      org.eclipse.core.runtime.CoreException - if creation failed
      Since:
      3.8
    • suggestLaunchConfigurationName

      protected String suggestLaunchConfigurationName(IJavaElement element, String fullTestName)
      Computes a human-readable name for a launch configuration. The name serves as a suggestion and it's the caller's responsibility to make it valid and unique.
      Parameters:
      element - The Java Element that will be executed.
      fullTestName - The test name. See org.eclipse.jdt.internal.junit4.runner.DescriptionMatcher for supported formats.
      Returns:
      The suggested name for the launch configuration.
      Since:
      3.8
    • getAttributeNamesToCompare

      protected String[] getAttributeNamesToCompare()
      Returns the attribute names of the attributes that are compared when looking for an existing similar launch configuration. Clients can override and replace to customize.
      Returns:
      the attribute names of the attributes that are compared
    • getLaunchConfigurations

      public org.eclipse.debug.core.ILaunchConfiguration[] getLaunchConfigurations(org.eclipse.jface.viewers.ISelection selection)
      Specified by:
      getLaunchConfigurations in interface org.eclipse.debug.ui.ILaunchShortcut2
      Since:
      3.4
    • getLaunchConfigurations

      public org.eclipse.debug.core.ILaunchConfiguration[] getLaunchConfigurations(org.eclipse.ui.IEditorPart editor)
      Specified by:
      getLaunchConfigurations in interface org.eclipse.debug.ui.ILaunchShortcut2
      Since:
      3.4
    • getLaunchableResource

      public org.eclipse.core.resources.IResource getLaunchableResource(org.eclipse.jface.viewers.ISelection selection)
      Specified by:
      getLaunchableResource in interface org.eclipse.debug.ui.ILaunchShortcut2
      Since:
      3.4
    • getLaunchableResource

      public org.eclipse.core.resources.IResource getLaunchableResource(org.eclipse.ui.IEditorPart editor)
      Specified by:
      getLaunchableResource in interface org.eclipse.debug.ui.ILaunchShortcut2
      Since:
      3.4