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

0
6 comments
Avatar
Permanently deleted user

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.

0

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

0
Avatar
Permanently deleted user

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?

0

Could you please link your project's sources?

0
Avatar
Permanently deleted user

Thanks for getting back to me. I will try to distill it into a public repo next week.

0
Avatar
Permanently deleted user

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!

0

Please sign in to leave a comment.