Package org.eclipse.jdt.junit.launcher
Class JUnitLaunchShortcut
- java.lang.Object
-
- org.eclipse.jdt.junit.launcher.JUnitLaunchShortcut
-
- All Implemented Interfaces:
ILaunchShortcut
,ILaunchShortcut2
public class JUnitLaunchShortcut extends Object implements ILaunchShortcut2
The launch shortcut to launch JUnit tests.This class may be instantiated and subclassed.
- Since:
- 3.3
-
-
Constructor Summary
Constructors Constructor Description JUnitLaunchShortcut()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ILaunchConfigurationWorkingCopy
createLaunchConfiguration(IJavaElement element)
Creates a launch configuration working copy for the given element.protected ILaunchConfigurationWorkingCopy
createLaunchConfiguration(IJavaElement element, String testName)
Creates a launch configuration working copy for the given element.protected String[]
getAttributeNamesToCompare()
Returns the attribute names of the attributes that are compared when looking for an existing similar launch configuration.IResource
getLaunchableResource(ISelection selection)
IResource
getLaunchableResource(IEditorPart editor)
ILaunchConfiguration[]
getLaunchConfigurations(ISelection selection)
ILaunchConfiguration[]
getLaunchConfigurations(IEditorPart editor)
protected String
getLaunchConfigurationTypeId()
Returns the launch configuration type id of the launch configuration this shortcut will create.void
launch(ISelection selection, String mode)
void
launch(IEditorPart editor, String mode)
protected String
suggestLaunchConfigurationName(IJavaElement element, String fullTestName)
Computes a human-readable name for a launch configuration.
-
-
-
Method Detail
-
launch
public void launch(IEditorPart editor, String mode)
- Specified by:
launch
in interfaceILaunchShortcut
-
launch
public void launch(ISelection selection, String mode)
- Specified by:
launch
in interfaceILaunchShortcut
-
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 ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element) throws CoreException
Creates a launch configuration working copy for the given element. The launch configuration type created will be of the type returned bygetLaunchConfigurationTypeId()
. The element type can only be of typeIJavaProject
,IPackageFragmentRoot
,IPackageFragment
,IType
orIMethod
.Clients can extend this method (should call super) to configure additional attributes on the launch configuration working copy. Note that this method calls
. Extenders are recommended to extend the two-args method instead of this method.createLaunchConfiguration
(element, null)- Parameters:
element
- element to launch- Returns:
- a launch configuration working copy for the given element
- Throws:
CoreException
- if creation failed
-
createLaunchConfiguration
protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element, String testName) throws CoreException
Creates a launch configuration working copy for the given element. The launch configuration type created will be of the type returned bygetLaunchConfigurationTypeId()
. The element type can only be of typeIJavaProject
,IPackageFragmentRoot
,IPackageFragment
,IType
orIMethod
.Clients can extend this method (should call super) to configure additional attributes on the launch configuration working copy.
- Parameters:
element
- element to launchtestName
- name of the test to launch, e.g. the method name or an artificial name created by a JUnit runner, ornull
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:
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 ILaunchConfiguration[] getLaunchConfigurations(ISelection selection)
- Specified by:
getLaunchConfigurations
in interfaceILaunchShortcut2
- Since:
- 3.4
-
getLaunchConfigurations
public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editor)
- Specified by:
getLaunchConfigurations
in interfaceILaunchShortcut2
- Since:
- 3.4
-
getLaunchableResource
public IResource getLaunchableResource(ISelection selection)
- Specified by:
getLaunchableResource
in interfaceILaunchShortcut2
- Since:
- 3.4
-
getLaunchableResource
public IResource getLaunchableResource(IEditorPart editor)
- Specified by:
getLaunchableResource
in interfaceILaunchShortcut2
- Since:
- 3.4
-
-