Open full view…

Where to put TestMe to be resolved from velocity templates?

Tue, 05 May 2020 11:08:25 GMT

Hello. I am trying to use parts of your code of the TestMe plugin in a bigger workflow that contains as a step Unit Test generation. I am using your code not as IJ plugin but as just 'code' or library. I am developing also a IJ plugin. Unfortunatelly I am struggling with your velocity templates. From TestMe with JUnit4 & the TestMe common cannot be resolved on runtime - throwing the error: "Velocity Error Error parsing file template: Unable to find resource 'TestMe'" I would like to know where to put the referenced velocity files so that they get resolved correctly on runtime? The velocity template 'TestMe with JUnit4 &' can obviously be found (I checked this in debug mode) but it crashes when the program tries to process the line: #parse("TestMe"). I have both: internal and testMeIncludes directories in the same directory structure as they are in your TestMe plugin. I have also tried to put the velocity files from testMeIncludes directory to internal directory, but with no success. I have seen i n your code that You have written some hacks for Velocity. If I understand your code correctly, this code ( gets only called as a part of TestMe Plugin initialization / loading. Your help would be highly appreciated. Best regards, Lubos Dobrovoda.

Tue, 05 May 2020 20:31:31 GMT

Hi Lubos, I can guess what is the issue based on your description, but can't be 100% sure. I hope this explanation helps. TestMe plugin is using the same Velocity Engine used by IDEA. In order to reuse the related code generation framework and get easy access to shared resources such as the user configured file headers such as `File`. Since the sdk has limited public api support, reflection was used to access internal api. In your use case, you will be initializing a Velocity engine directly. The code you referenced that performs these load time hacks is not relevant for you. all you need is to set the classpath of included resources for the velocity engine you are initializing. You can either provide a configuration file, such as or do that programmatically - Please note that this holds true to the Velocity library used by IDEA ( I think it's v1.7). If your using version 2.x, it might be a bit different - Happy hacking :) Yaron

Fri, 08 May 2020 03:45:11 GMT

Thank You very much for your detailed answer. I have solved the problem in a different way but nevertheless once more thankx for your time ;)