25

In Eclipse, (if I remember correctly) I could run a JUnit test almost instantaneously with virtually no startup time. This meant I could do a codechange+test cycle in a couple of seconds.

I've recently migrating to IDEA IntelliJ, which seems to have to "make" the project before running a unit test if you've changed any source code since the last time. This typically takes 20 seconds for me, which is too long especially for test-driven development.

I can uncheck the "Make before launch" checkbox in the Run Configuration, but then the test is executed without compiling recent changes.

The warnings output during the "make" indicates that it is doing some aspect weaving for at least some of the time. I would imagine that aspects aren't generally wanted for unit testing.

My guess is that Eclipse was constantly compiling in the background every time you changed a source file, and doing so rapidly without doing the aspect weaving.

How can I speed up my codechange+test cycles in IntelliJ?

more info: I have "Compile in background" checked in Compiler Settings. The Java Compiler is ajc in com.springsource.org.aspectj.tools-1.6.8.RELEASE.jar

spikemanuk
  • 432
  • 1
  • 5
  • 13
  • Is there a reason why you're not using plain javac? – jackrabbit Oct 27 '11 at 11:12
  • We're using ajc because our webapp uses aspects, some from the Spring framework I believe, and some of our own. – spikemanuk Oct 27 '11 at 14:01
  • This stackoverflow post sounds promising: [Intellij idea tests compilation takes too long (compared with Eclipse)][1] [1]: http://stackoverflow.com/questions/1141923/intellij-idea-tests-compilation-takes-too-long-compared-with-eclipse – spikemanuk Nov 15 '11 at 14:37

2 Answers2

12

Pragmatic answer: switch the compiler from "ajc" to "Eclipse" during test-driven development. Remember to revert it when you're deploying the application!

spikemanuk
  • 432
  • 1
  • 5
  • 13
12

The options i activated in IntelliJ, speeding up tests execution from 20s to 2.5s:

Compiler

  • Make project automatically
  • Compile independend modules in parallel

Compiler -> Java Compiler

  • Use compiler: Eclipse
  • Generate no warnings
PaoloC
  • 3,817
  • 1
  • 23
  • 27