Run JUnit in IntelliJ, ignoring a compilation error in an unrelated class?

When running a JUnit test case in IntelliJ, it opens the Make console and shows complexity errors in an unrelated class.

  • Is it possible to run a test case ignoring these errors?

  • Is there a way to do this, not to compile the entire project when running test cases, but only those class files that are required in the test case?

+8
java intellij-idea
source share
1 answer

Yes, you can.

You can disable Make before starting.

(For IntelliJ 14 it’s written: different versions may have slightly different layouts, but as far as I remember, these parameters were the same for a while)

For one test

  • Go to the "Run" - "Edit Configurations ..."
  • Select test case configuration
  • On the tab with the name "Configuration" there is a list of "Before starting" with one entry "Make". Delete this entry.
  • Confirm with OK

For all tests:

If you want to remove this by default for all new test configurations (which may not be a good idea, since you build manually all the time when running tests)

  • Go to the "Run" - "Edit Configurations ..."
  • Select "Defaults" in the tree
  • Select a test program (most likely Junit or TestNG)
  • On the tab with the name "Configuration" there is a list of "Before starting" with one entry "Make". Delete this entry.
  • Confirm with OK
+13
source share

All Articles