15

I am new to using IntelliJ. I have only one grievance and that's the compiler. I prefer the way the Eclipse compiler will compile a project and skip classes with errors in them.

This is particularly a problem for if I want to write a unit test for a method I have to fix all errors in the entire project for running a single unit test!

You might say fix your project but I'm working on a project where people have already committed code with errors in it. How can I get around this, I saw there's an option to use the Eclipse compiler in the settings but this has made no difference/I don't know the argument to skip errors.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Luke De Feo
  • 2,025
  • 3
  • 22
  • 40
  • Disable `Make` in the tests Run configuration. – CrazyCoder Oct 23 '12 at 13:34
  • 2
    Thanks that worked, any idea how to go one step further and get full eclispe like compilation so i can build a project ignoring broken/irrelevant classes? – Luke De Feo Oct 23 '12 at 14:24
  • Actually that doesnt work if i set the default to not make, it doesnt even build the test class and hence can run it. anyone know how to get the eclipse compiler to work in intellij – Luke De Feo Oct 23 '12 at 14:40
  • See http://stackoverflow.com/q/12744303/104891 – CrazyCoder Oct 23 '12 at 15:55
  • I'm having the same problem with Test files not fully built right now. But won't let me run without commenting all these out. – Zach May 23 '23 at 16:22

5 Answers5

5

This fixed it for me on IntelliJ 14:

  • In Preferences->Build,Exec,Deploy->Compiler->Java Compiler, choose Eclipse compiler. Then check "Proceed on errors", which will appear once you choose the Eclipse compiler.
  • Then in Run->Edit Configurations expand the Defaults section on the left. Choose the configuration for your unit test framework (eg, JUnit or TestNG).
  • Then in the "Before launch" section, remove "Make" and add "Make, no error check"
  • Finally, you may need to delete any existing unit test run configurations so the new launch setting will take effect.
colini
  • 736
  • 8
  • 11
  • 1
    This should be "File->Settings .. etc. And "Build, no error check". If you are using Spring, then you may need to mark top level component as @Lazy(true) so that Spring application context can get safely initialized. – Apurva Singh Oct 05 '17 at 13:53
1

Not sure if this will be effective for what you're attempting to do and how your project is structured, but it worked perfectly well for me in my particular case, in that if your class has a main method, you can right click inside of the actual main method code and select "Run 'classname.main()'" from there.

This worked for me, but obviously may not be identical to your situation.

I got this from another answer located here: Intellij IDEA how to run a class not the entire project?

Community
  • 1
  • 1
1

On IntelliJ 2018.1.4 (Linux): 2018-06-06

  1. In File->Settings->Build,Exec,Deploy->Compiler->Java Compiler, choose Eclipse compiler from drop down. Option "Proceed on errors" should already checked (if not, mark tick on it), which will appear once you choose the Eclipse compiler.
  2. Then in Run->Edit Configurations -> expand the Defaults section on the left. Choose the configuration for your unit test framework (eg, JUnit or TestNG).
  3. Then in the "Before launch: Build,Activate tool window" section(see in end), remove "Build" and add "Build, no error check". Click apply and okay
  4. Finally, you may need to delete any existing unit test run configurations so the new launch setting will take effect. This can be find from Run->Edit Configurations under (eg, JUnit or TestNG). or we can edit it
0

A clumsy way is to create a new module under your project file and make a test file in src folder of this new module

Neuvn
  • 1
  • 1
0

You can mark other directories which you have errors as "excluded" by right clicking on it. Therefore, the test classes will not be compiled.

EMRE BİNNAZ
  • 43
  • 1
  • 8