Results 1 to 3 of 3

Thread: Testing custom addon

  1. #1
    Join Date
    Jul 2012
    Posts
    5

    Default 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?

    Thanks

  2. #2
    Join Date
    Jul 2012
    Posts
    5

    Default

    Must build a project first duh.

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

  3. #3
    Join Date
    Jun 2008
    Location
    Philadelphia, PA, USA
    Posts
    212

    Default

    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 PomManagementServiceImplTest.java 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 http://www.rimple.com/silly-weasel/ 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.


    Quote 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.
    Ken Rimple
    Chariot Solutions
    email: krimple@chariotsolutions.com
    work: www.chariotsolutions.com/education
    personal: www.rimple.com

    Author: Spring Roo in Action (Manning)
    MEAP Site: manning.com/rimple

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •