Can't cast instances from JUnit plugin
I'm trying to get access to the current JUnitConfiguration object:
RunManager runManager = RunManagerEx.getInstance(project);
RunnerAndConfigurationSettings settings = runManager.getSelectedConfiguration();
RunConfiguration someConfig = settings.getConfiguration();
if (someConfig instanceof JUnitConfiguration) {
return (JUnitConfiguration) someConfig;
} else {
return null;
}
However, the instanceof check fails, even though I did add this line to my plugins.xml:
JUnit]]>
When stepping through in the debugger, it appears that someConfig is an instance of JUnitConfiguration but from a different class loader, so I can't cast it. Is there something else I need to do to fix the classloader issue?
Incidentally, the plugin.xml for JUnit only defines a name for this plugin ("JUnit") but not an id.
Please sign in to leave a comment.
A bit more about this. The original mistake was that I added plugins/junit/lib/idea-junit.jar from the IntelliJ distribution as a module library, so this jar was copied into my plugin. However, I don't know the correct way to add a dependency on another plugin that's included as part of the IntelliJ distribution. I tried creating a plugin module with a plugin.xml that has 'JUnit' as its name and plugins/junit/lib/idea-junit.jar as a module library, but this causes another JUnit plugin to be created in the sandbox directory, so JUnit doesn't work anymore.
Hello Brian,
You should add the JUnit plugin jar file to your IntelliJ IDEA SDK, rather
than add it as a project or module library.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thanks!