Menu

#114 Custom mocking templates

Version 3.0.2
closed-fixed
None
5
2015-01-21
2013-05-31
No

From feedback mails:

Hmph. I thought I figured this out. I found the non-empty
"templates" folder in "plugins/org.moreunit.mock_3.0.2.jar". I
extracted that "mockito.xml" and copied it to
"$WORKSPACE/.metadata/.plugins/org.moreunit.mock/templates". I
modified this file, changing the "mocking-template" with id of
"org.moreunit.mock.mockitoWithAnnotationsAndJUnitRunner1.9", in the
"mockitoRunnerDeclaration" template, I changed "MockitoJUnitRunner" to
"VerboseMockitoJUnitRunner". I used Process Monitor to verify this
file is being read when I click on "Reload templates" in the MoreUnit
preferences. However, when I generated a test class (using Mockito
and "With Annotations"), it still referenced "MockitoJUnitRunner".

On Tue, May 28, 2013 at 9:37 AM, David Karr davidmichaelkarr@gmail.com wrote:

I was wondering if there was some way that I could change what test
runner MoreUnit references in the default templates, and then I
noticed the information in the MoreUnit preferences, which says:

"You may add custom templates by placing them in the following folder:
plugins/org.moreunit.mock_3.0.2.jar/templates/

Please refer to MoreUnit's documentation for more information."

There are a few problems with this.

First, I'm not completely certain where this "plugins" directory is.
I imagine it's where I've installed Eclipse, although my workspace has
a ".metadata/.plugins" directory. It's likely the former, but in my
Eclipse installation, "plugins/org.moreunit.mock_3.0.2.jar" is
actually a jar file, as it's name implies, and there is no "templates"
folder in that jar. Finally, I see no mention of templates in the
MoreUnit documentation.

Discussion

  • Vera Henneberger

    Documentation should be updated with a description how to use custom templates and the label in the preferences needs an update too (still refers a jar from an older version).

     
  • Vera Henneberger

    I have tried to reproduce the template problem and do have some problems too.
    The attached file is a simple test template.
    If I put it into the templates folder (WORKSPACE/.plugins/.org.moreunit.mock/templates) and press reload in the preferences only MyMockito show up but the second popup does not seem to get updated if I choose MyMockito.

     
  • Nicolas Demengel

    The problem of the attached test template is that the ID "org.moreunit.mock.mockitoWithAnnotationsAndJUnitRunner" is already used.

    For the record, here is the answer I gave by email:

    "Hi David,

    Sorry for the inconvenience. The thing is, we exposed this feature when a specific user asked for it, but we waited for it to be stabilized before frankly "exposing it" to the world. And as usual in such situations, we finally did not document it at all :-\

    Regarding the path displayed in the preferences, this is a bug and we will fix it (maybe we will also add a wizard some day to load template files). As for the fact that your file is ignored, it is because you are trying to redefine an existing template, which we chose to forbid. You must copy the section you want to change, and give it another ID (e.g: org.moreunit.mock.mockitoWithAnnotationsAndVerboseJUnitRunner). We will document those things, and display a message to users when such an error occurs.

    Regards,
    Nicolas"

     
  • Nicolas Demengel

    I found some time to work on those problems this week-end. You can install an early release of it from the following update site: http://moreunit.sourceforge.net/latestandgreatest

    Here are the modifications:
    - the path to the tempates has been fixed
    - the (raw) errors that might occur when loading templates is displayed in a pop-up window
    - there is a link to the existing templates in our documentation (and I'm currently writing a complete doc regarding those templates)

     
  • Nicolas Demengel

    Missing bits of documentation have been written, and there is now an XSD. Closing the issue.

     
  • Nicolas Demengel

    • status: open --> closed-fixed
    • assigned_to: Nicolas Demengel
     

Log in to post a comment.