0

I have written a custom launcher in Eclipse which I can access via the "Run As" and "Debug As" on class level. I have a similar configuration as described in How do I use "org.eclipse.debug.ui.launchShortcuts"?. Unfortunately I can't see the submenu in the package explorer at the method level (for example submenu to launch the customer launcher in order to execute a single JUnit test). How can I do this?

surfspider
  • 727
  • 3
  • 11
  • 25

1 Answers1

1

JUnit uses a contextualLaunch based on the selected element being a org.eclipse.jdt.core.IJavaElement rather than just a resource. You will need to do the same.

This is what JUnit uses:

<contextualLaunch>
     <enablement>
         <with variable="selection">
             <count value="1"/>
              <iterate>
                <adapt type="org.eclipse.jdt.core.IJavaElement">
                    <and>
                        <test property="org.eclipse.jdt.core.isInJavaProject"/>
                        <or>
                        <test property="org.eclipse.jdt.core.hasTypeOnClasspath" value="junit.framework.Test"/>
                        <test property="org.eclipse.jdt.core.hasTypeOnClasspath" value="org.junit.platform.commons.annotation.Testable"/>
                        </or>
                        <test property="org.eclipse.jdt.junit.canLaunchAsJUnit" forcePluginActivation="true"/>
                    </and>
                </adapt>
             </iterate>
         </with>
    </enablement>
</contextualLaunch>

Some of the <test elements are specific to JUnit so you will need to use something different.

greg-449
  • 109,219
  • 232
  • 102
  • 145