Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuous testing with IntelliJ Idea

I'm looking for an IntelliJ IDEA plugin that would run my tests each time I change my code. I looked for such a solution and I found:

  • Infinitest, which works, but is inconvenient because I need to add the facet to each module, and it opens a new tool window for each module (which means 15 tool windows for me).
  • Fireworks - didn't work for me, maybe it just doesn't work with IDEA 14 (in its repo I can see that last changes were made in 2009). IntelliJ also reports that it throws exceptions.

There are lots of ways I could run all my tests (including writing a simple script for this), but I'm looking for a tool that would be smart enough to rerun failed tests first, and that would understand module dependencies (so after a change in some module it would run only tests of dependent modules).

I prefer free options, but if there's something paid for a reasonable price, I would accept it as well.

like image 402
mik01aj Avatar asked Nov 27 '14 14:11

mik01aj


People also ask

How do I generate test cases automatically in IntelliJ?

In your production code in the editor, place the caret at the class for which you want to create a test, press Alt+Enter , and select Create Test. In the Create Test dialog, select the library that you want to use. If you don't have the necessary library yet, you will be prompted to download it. To do that, click Fix.

Does IntelliJ run tests in parallel?

Answering late for posterity. You can make JUnit tests run in parallel (or serial) to any level of granularity in IntelliJ by changing the Fork mode in the test's run configuration. Be careful not to confuse this with the Allow parallel run option, which lets you start the test execution multiple times within your IDE.


2 Answers

IntelliJ now actually has a Toggle auto-testin the run dialog. Just run a run-configuration and then select Toggle auto-testin the run dialog.

It's not as intelligent as you would have hoped. It just reruns when it detects changes.

like image 172
mathiasbn Avatar answered Sep 21 '22 00:09

mathiasbn


I know this is a 3-year-old question but I think it will help people who face the similar problem in future. So I found out a way to enable SBT style auto test execution in IntelliJ studio.

We need to do 2 things to enable auto test execution.

  1. Enabling auto project build - This can be done in settings by going into File -> Settings -> Build, Execution... -> Compiler and selecting "Build Project automatically".

enter image description here

  1. Enabling "Toggle auto-test" in run dialog box

This will start auto testing. Although this works fine, it takes time to build the project even when my project is tiny so for larger projects it will certainly take very long time to complete the build and execute tests.

Reference: Original article which explains these steps

like image 21
Shekhar Avatar answered Sep 21 '22 00:09

Shekhar