RunConfigurationProducer extension not loaded in test

Answered

I wanted to contribute to [KotlinTest IntelliJ plugin](https://github.com/kotlintest/kotlintest-intellij-plugin) and fix a bug with context configuration not being properly provided (https://github.com/kotlintest/kotlintest-intellij-plugin/issues/20). I wanted to first write unit tests for this case, but I can't seem to have run configuration producers loaded in tests.

`idea.xml` file has couple of producer entries, like `<runConfigurationProducer implementation="io.kotlintest.plugin.intellij.BehaviorSpecRunConfigurationProducer"/>`. I'm using `LightCodeInsightFixtureTestCase` as the base class for tests, and I'd expect that producers are properly loaded. However, even printing out `RunConfigurationProducer.EP_NAME.extensionList` in a test only yields producers provided by IntelliJ or Kotlin, and not the ones defined in `idea.xml`

Is there something I'm missing about what to expect? I wanted to continue by checking `ConfigurationContext(innerMethodPsi).configurationsFromContext` but of course it returns `null` right now.

3 comments
Comment actions Permalink

Can you execute any of the other tests locally? Please try clearing your test's sandbox.

1
Comment actions Permalink

Thank you! Indeed, something is wrong with the configuration. Your comment prompted me to run tests directly from Gradle (which I should've done in the first place) and I do see custom producers loaded there. Turns out the project was using `Intellij IDEA` as test runner in `Build, Execution, Deployment -> Build Tools -> Gradle -> Build and run`. Changing it to Gradle fixes the issue.

Is this a limitation of IntelliJ runner? Should I verify some other configuration? I imported the project from gradle.settings file.

0
Comment actions Permalink

Yes, you must use Gradle runner as it setups classpath and necessary config parameters for running plugin tests.

1

Please sign in to leave a comment.