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
Stop tests Click. or press Ctrl+F2 to terminate the process immediately. Click. to terminate the process gracefully, allowing shutdown hooks to run.
Show activity on this post. Open the class where the tests are located and check the part where inteliJ shows the the number of lines, at the beginning of each test method there is a green icon (looks like a play button) just hit that icon and the specific test method will be executed.
IntelliJ IDEA Unit Test We can run all unit tests inside the IntelliJ IDEA. IntelliJ IDEA has various unit testing frameworks like JUnit, TestNG and many more. In this section, we will understand how unit test work.
Generally, IntelliJ IDEA runs and debugs tests in the same way as other applications, by running the run/debug configurations you have created. When doing so, it passes the specified test classes or methods to the test runner. In many cases, you can initiate a testing session from a context menu.
Rerun tests automatically In IntelliJ IDEA, you can enable the autotest-like runner: any test in the current run configuration restarts automatically after you change the related source code. Click Toggle auto-test on the Run toolbar to enable the autotest-like runner.
When you run a test, IntelliJ IDEA creates a temporary run configuration. You can save temporary run configurations, change their settings, share them with other members of your team.
Pragmatic answer: switch the compiler from "ajc" to "Eclipse" during test-driven development. Remember to revert it when you're deploying the application!
The options i activated in IntelliJ, speeding up tests execution from 20s to 2.5s:
Compiler
Compiler -> Java Compiler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With