Announcement Announcement Module
No announcement yet.
Testing custom addon Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing custom addon

    I am currently having issues testing a custom addon. I can test it locally using osgi while my directory is pointed to the addon. I need to be able to change my directory folder then still be able to test my addon using osgi or otherwise.

    Anybody have a link with some help or any advice?


  • #2
    Must build a project first duh.

    New question....I need to be able to access my addon without a project.


    • #3
      To unit test an add-on you don't have to be in a Roo project. When you osgi start your addon, it is loaded to the shell, not the project. So you can just fire up the shell in another directory and hand-test it.

      The only testing I've done with a Roo add-on is using unit-level tests. Were you doing something more in-depth, like booting an OSGi container, or Roo, in a Junit test? I know there's a Spring dynamic modules base unit test class AbstractBundleCreatorTests, but then you'd also have to add the core Roo framework as well.

      To fake out that you're not in a project, you can just mock the Project Operations class and return false for isFocusedProjectAvailable()

      To look at some in-depth mocking to test components of Roo itself, check out in the roo source code. They use Mockito to mock out Roo services. This is what I've been doing in my add-ons in general, although I use a Spock add-on I've created since I like testing code with Groovy. My tests and the add-on are available at if you're interested in another developer's take.

      I'm not sure personally how to do integration-level testing, and to note it's not anywhere in the source code of Roo either. I think we may want to see if we can get the Roo team to put in something like a @ContextConfiguration / @RunWith class for booting Roo in a junit test, then giving us access to a shell object for execution of the add-on under test and evaluation of the Roo system state and result.

      I guess a secondary way to do it would be to treat Roo as a total white-box, and automate executing the shell and 'scraping' the output. But that is probably too complicated as well.

      Originally posted by Destro190 View Post
      Must build a project first duh.

      New question....I need to be able to access my addon without a project.