EclEmma as dependency of a new plugin

2012-06-29
2013-04-24
1 2 > >> (Page 1 of 2)
  • Hi everyone,

    First of all, I am a newbie in eclipse plugin development.
    Next, I am starting to develop a new plugin that intends to use EclEmma to run some test classes after a previous mapping to a given concern.
    Up to now, I didn't find how I can launch a coverage session based on a set of test classes. In addition, didn't find a documetation, such as a javadoc to help me in this task, so I decide to ask you about.

    Does anybody here could help me?

    Thanks in advance.
    ps: I am using the sourcecode of the tag v2.1.2.

     
  • Hi,

    I would like to thank you a lot Marc for reply. It give me a path to follow.

    Best regards,

     
  • Hi,

    After read and study the eclemma code I noticed the scope of a JavaApplicationLauncher, which is used by the launchDelegate of JUnit and TestNG, for example, is defined by a IPackageFragmentRoot. Please correct me if I am wrong.

    Since my new plugin does not intends to launch eclemma from a IPackageFragment, instead, I am going to launch from a new group of testes  being displayed in a treeview in my own view. How can I get my treeview node into the scope of eclemma launch, once the IPackageFragment is not intended to be implemented by clients.?

    Thanks in advance.
    's

     
  • Hi,

    the scope (defined by a set of IPackageFragmentRoots) defines what classes will be analyzed for code coverage. Basically this is the content of the Coverage view after your application terminated. The scope does not define what is actually executes, this is defined by the specific LaunchDelegates. The coverage mode launcher itself does not launch any processes, it simply delegates to the corresponding run mode launcher.

    So what you need first is a launcher that executes your scenario (defined by your tree view) in normal run mode. Then you can easily define an EclEmma wrapper to add the code coverage mode for this (of course the application under test has to run under a Java VM).

    Cheers,
    -marc

     
  • Hi,

    What do you mean by easily define an EclEmma wrapper? I have tried to add a new instance of CoverageAsAction to the MenuManager of the popup menu of the treeview node but it didn't work.

    Even though the Coverage As,,, menu shows at the poppup menu,  it didn't contain any submenu, such as "JUnit Test" or "TestNG Test" and I didn't realize how to get it in.

    Thanks in advance.

     
  • Hi,

    what I proposed was to implement a "Run as…" option first and have a working launch type. This probably the hard work if you can't directly use one of the existing types (Java, JUnit, etc). Once you managed to implement a new launch type with the Eclipse debug framework, you will see adding a extra launch mode for it is quite easy and simply a matter of declaring some additional extension points.

    As said before: The interesting part here is to get into the Eclipse debug framework.

    Cheers,
    -marc

     
  • Hi Marc,

    I'm still working on this launcher. Now I already have my view implemented and ready to add the eclemma lauching. After read this article (http://www.eclipse.org/articles/Article-Launch-Framework/launch.html), which seems to be useful, even though it is really old, a doubt  come to my mind.

    I could not realize if I must implement my own launching or only put launchMode, lauchDelegates and other staff to my plugin.xml and points to EclEmma implementation. My plugin should be able to launch a sort of test classes attached to one of the treeview nodes, through right-clicking and coverage as… junit tests. Any help?

    After that, is there some way to retrieve the code color highlighting? I mean, is there some way to retrieve the portion of code executed by the EclEmma coverage session?

    I want to say that I really appreciate your help up to now, and I hope it continues. Actually, it has been the most helpful one.

    Thanks again!
    -alcemir

     
  • Congratulations! This was actually the hard part.

    To add coverage mode support for your launch type you have to add some more extension points. Please have a look at the plugin.xml files of eclemma.core and eclemma.ui: If you search for example for "scala" you see what has to be defined for a particular launch type.

    The code coverage highlighting will be automatically available for all package fragment roots in scope if you open an Java editor. If you want to access it programatically you can adapt any IJavaElement in scope to org.jacoco.core.analysis.ICoverageNode (and its subtypes) if a coverage session is active.

    Cheers,
    -marc

     
  • Hi Marc,

    I added all the extension point in my plugin.xml, the lauch appear and launch the coverage session, but in the wrong place. It appers at project explorer instead of my own view.

    This setting is made programatically or also at the plugin.xml? I could find any reference to where the launchShortcut should appear in the extensions I've just added.

    Thanks in advance!

     
  • I have found that it may be related to the actionSet configuration right?
    I did not define anyone.

    Additionally, in the "Coverage As…" action of eclemma.ui actionSet i found this declaration:

     menubarPath="org.eclipse.ui.run/emptyLaunchGroup"
    

    I noticed that "org.eclipse.ui.run" is a reference to a menu previously defined in the same actionSet, am I right? And What about the "/emptyLaunchGroup"?

     
  • Sorry, I failed to noticed the saparator.

    <separator name="emptyLaunchGroup"/>
    
     
  • Does the "Run as…" menu appear in your view?

     
  • No, it doesn't.  Acctually, I was thinking about add a context menu with a "Coverage As…".

    My view show a treeview, just like this:

    - a parent node
    ---> a test class (a child)
    ---> another test class (another child)
    - anoteher parent node
    ---> a test class (a child)
    ---> another test class (another child)
    

    What I'm wishing is after a right-click at one of the "parent nodes" the context menu with "Coverage As…" pop up.

     
  • Ok, then you view seems to miss some of the infrastructure Eclipse requires to add launch shortcuts. Some things to check:

    - Is the viewer registered as a selection provider?
    - Do you use a menu manager that accepts contributions?
    - Do the elements in your tree fulfill the conditions that you have declared in your launch shortcut?

    Cheers,
    -marc

     
  • I'm afraid not. But I have to check I haven't this for sure.

    As soon as I get the answers I give you a reply.

    After this checklist done, is my view able to receive the launch shortcut?

     
  • - Is the viewer registered as a selection provider?

    Yes, it is.

    - Do you use a menu manager that accepts contributions?

    Yes again. Actually, I already tried to add a "Coverage As" in this way…

    pManager.add(new CoverageAsAction());
    

    …it appears when right-clicking, but no subitem like "JUnit Test" appears.

    - Do the elements in your tree fulfill the conditions that you have declared in your launch shortcut?

    Here is my launchShortcut declaration:

    <extension
             point="org.eclipse.debug.ui.launchShortcuts">
          <shortcut
                label="JUnit Testt"
                icon="icons/junit_launch.gif"
                class="com.mountainminds.eclemma.ui.launching.CoverageLaunchShortcut:org.eclipse.jdt.junit.junitShortcut"
                modes="coverage"
                id="com.mountainminds.eclemma.ui.junitShortcut">
             <contextualLaunch>
               <enablement>
                 <with variable="selection">
                   <test
                        property="com.mountainminds.eclemma.ui.launchable" 
                        args="org.eclipse.jdt.junit.junitShortcut"/>
                 </with>
               </enablement>
             </contextualLaunch>
          </shortcut>
       </extension>
    

    How can I check if my element fulfill the conditions?

     
  • As said before: Please first make it work for the "run" mode.

    How can I check if my element fulfill the conditions?

    Well, you just implemented the launch shortcut for your launch type, right? So you should know when your context launch is enabled and whether the objects in your tree fulfill this condition. The generic coverage launcher simply delegates to your run mode implementation.

     
  • I'm sorry by make you repeat de tips/advice. I am a newbie and sometimes i might think i am done with it when i didn't.

    By "work for the run mode" as well as "a launcher that executes your scenario (defined by your tree view) in normal run mode" you mean…

    # option 1
    Have I to implement a ParentNodeLaucher exectly as EclEmma did with "com.mountainminds.eclemma.core.launching.EclipseLauncher" and "com.mountainminds.eclemma.core.launching.JavaApplicationLauncher"? And consequently implement the method public Set<IPackageFragmentRoot> getOverallScope(); ?

    # option 2
    Have I to implement   ILaunchConfigurationDelegate (or ILaunchConfigurationDelegate2) ?

    # option 3
    Neither of above alternatives. And so, please give me a path, i mean, as specific as you can. (… and please don't misundertand, i don't want you to do the things for me.) Actually, i have never developed a plugin in my life, and this posts are the only guide to get my work done.

    I waste some hours searching for how to get my scenario work for the run mode, and i don't even know for sure if the results i got was i really need. =(

     
  • Hi Marc,

    I have been thinking about my plugin and i see that if chnge my approach it can turns my life easier.

    What about "JUnit Test" launchMode be avaiable when I select my treeview node? What should I do to get this enabled?

    Best regards,

     
  • Hi Marc,

    I searched about how to get my treeview node works like a package, but it is not a good path since didn't have any folders representing my treeview and IPackageFragmentRoot is not intended to be implemented.

    I have been thinking about my plugin and i see that if chnge my approach it can turns my life easier.

    What about "JUnit Test" launchMode be avaiable at actionSet "Coverage" when I select my treeview node? Maybe, if I put the workspace references to the classes attached to my treeview node into the launchConfiguration. What should I do to get this enabled?

    Best regards,

     
  • Hi Marc,

    I really miss your advice. Here is how my is looking like:


    When I right-click in the "New Feature" tree node of "Map View" I have a "Coverage As…" contextual menu, but a "(none aplicable)" option appear. Even though, when I access the contextual menu at the package explorer  o "launchShortcut" I have declared appear there.

    Thanks,

     
  • Hi Alcemir,

    sorry for not following up this thread currently. My day time Job and some blocker issues with JaCoCo keeps me busy. Also please understand that I'm happy to discuss EclEmma/JaCoCo specific questions here but my limited time budget does not allow to provide general Eclipse coding support.

    So I can only re-iterate my initial advice to ignore code coverage for the first step: Make sure your scenario executes in regular run mode. Once you're familiar with the Eclipse debug framework and have run mode available it's easy to add the code coverage mode. As you mentioned in your previous post I would also try to use an existing launch type like "JUnit Test".

    Beside documentation there is
    a friendly forum at Eclipse.org to get general help with the platform.

    Good luck!
    -marc

     
  • Hi Marc,

    I understand your point. And I'm always trying another sources of  help.  Thanks again.

    I've just discovered that if I declare a adapter at plugin.xml i can have all the run methods (Run as,  Debug as, and Coverage As) when right-clicking at my New Feature Node.

    Actualy, I am already using the documentation. but now I am going to look for help in the forum too.

    Cheers!
    -Alcemir

     
  • This great news! If you

    a) get the "Run as" Menu with the right adapter and
    b) you use an existing launch type like "JUnit Test" that is already supported by EclEmma

    you should be done!

    Cheers,
    -marc

     
1 2 > >> (Page 1 of 2)