Search code examples
intellij-ideajunit

Is there a way to run a JUnit test for a particular class in IntelliJ without compiling the entire project?


I have a project in IntelliJ that has a number of syntactically correct and incorrect classes and a unit test that I've written for a particular class.

Is there a way to execute the test even though other classes, completely independent from the current class I want to test, have errors that prevent the entire project from compiling?

The class I want to test has no compile-time errors. When I try to run the test, I'm directed to those other classes with syntax errors.


Solution

  • Replace the Before launch Build step with Build, no error check:

    no error check

    Do this change for the default JUnit configuration (under Defaults node in the tree on the left) so that it's applied to all the new JUnit run/debug configurations automatically.

    You can also remove the Build step and compile the test files manually (from the file right click context menu):

    recompile