Isolating IntelliJ Plugin Tests Using Temporary Project Directories

When testing a plugin for IntelliJ-based IDEs using a UI test, the plugin gets to operate within a fully-featured instance of the IDE. Most tests will therefore require a project to perform their actions on. This opens a question: How do you deal with modifications to test projects made by tests? Add undo logic at the end of every test? Revert using a version control system? Those options sound like easy ways to make new mistakes.

We faced the same problem when writing tests for our own plugin, Symflower, for IntelliJ IDEA and GoLand, but we’ve opted for a simpler solution. We don’t run tests on the canonical source of our test projects but rather copy the entire project directory and use that copy instead. This avoids relying on repetitive cleanup logic or VCS-based reverting that could undo legitimate changes to the source files.

Getting Started With Plugin Development for JetBrains IDEs Like IntelliJ and GoLand

No matter what your technical background as a developer looks like, you’ve probably come across or even used an IDE from JetBrains. Their product line features IDEs for various languages and technologies and they’re all built according to the same schema: Atop an extensible core (“IntelliJ platform”) sits a set of curated extensions that provides all of the “integrated” functionality of the IDE.

But what if you could extend your IDE further with your own plugins? Doing your own plugin for your workflows can improve your productivity drastically. In this post we’ll explore the IntelliJ API and build a simple plugin step-by-step to get you going.