Unit Testing a custom PsiAugmentProvider?
I'm writing a custom PsiAugmentProvider for a Project Lombok plugin (http://projectlombok.org). Are their any open source examples of unit testing something like this? I'm not clear how to mock up the environment so the calls to static methods can return things like the JavaPsiFacade and Extension Points (call to Extensions.getExtensions(...) in PsiAugmentProvider).
I hear mentioned that the AspectJ functionality uses this but I don't see it in the source for the Community Edition.
Please sign in to leave a comment.
Hello Brian,
In our experience, trying to set up a mock environment for testing IntelliJ
IDEA plugin code is nearly always a bad idea. Your own code is just a small
piece of the big environment, and most of the problems related to the plugin
code arise in its relationship with the environment around it. Trying to
mock the environment creates extreme fragility and greatly reduces the value
of a test.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thanks Dmitry,
I copied the Groovy parsing tests as an example to test my PsiAugmentProvider, but it does not appear the augmenting occurs during the test run. I can launch my plugin in the sandboxed IDEA instance and see it working. But if I run it as a test my provider doesn't appear to run and augment the PSI tree. You can see the code here: https://github.com/jaxzin/lombok-idea
Thanks,
Brian