How to create Maven pom.xml for test
Answered
Hi,
I am developing an IDEA plugin, which accesses the Maven `pom.xml` files of a project using the provided Maven `DomElement` types. In the plugin this works perfectly fine, but now I would like to write a test case for my plugin and don't know how to create a `pom.xml` file in the test. My test class extends `LightJavaCodeInsightFixtureTestCase`. I have tried creating a file named `pom.xml` using `myFixture.configureByText()` and I do get an `XmlFile` from this, but `DomManager#getDomElement()` etc. return `null`. Is this because the file is created in the wrong place? Any help would be appreciated.
Thanks,
Knut
Please sign in to leave a comment.
Please let me know if you need any more details or if it would be better if I filed a support request for this question.
Please make sure "Maven" plugin (responsible for DOM of pom.xml) is added as dependency https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
Yes, the dependency is there, both in the Gradle build script and the plugin.xml file. And as I said my plugin works correctly when I start it with runIde. But when I add a test source to the fixture as described, I cannot get the DOM model for it. Any other reason you can think of? Any specific way I need to set up the project in the test fixture?
Could you please link your project's sources?
Thanks for getting back to me. I will try to distill it into a public repo next week.
Meanwhile I can no longer reproduce the problem. I don't know if some restart could have fixed this, but all the sudden my unit test which previously failed, now works :-) Thanks for your help!