26

I have a large suite of tests that takes about half an hour to run and would love to be able to the test classes in parallel.

Is there a way to do that with IntelliJ IDEA 9?

Omer van Kloeten
  • 11,800
  • 9
  • 42
  • 53
  • 1
    Not a dupe question (as this Q is for IntelliJ) - but there is some discussion here: http://stackoverflow.com/questions/423627/running-junit-tests-in-parallel – Noel M Aug 24 '10 at 11:47
  • someone might be interesting this: https://www.baeldung.com/junit-5-parallel-tests – NanoNova Mar 17 '23 at 10:06

3 Answers3

7

IDEA will understand parallel JUnit tests only since version 10.

There is a tracker issue which you can vote for and watch for progress: http://youtrack.jetbrains.net/issue/IDEA-47103

We plan to add it in IDEA 10, but the priority would depend on the number of votes.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • It does not work for many cases even with the Fork Mode "Method". For JUnit 5 and @TestFactory with DynamicTest instances it is also run sequentially and IDEA doesn't even offer any fork mode! – Baradé Jul 17 '23 at 14:19
7

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.

To specify the parallelization of a JUnit test (or group of tests) in IntelliJ, open the Run Configuration for that test and change the Fork mode setting or the Allow parallel run setting. This image depicts IntelliJ IDEA 2018.3.4

JJ Brown
  • 543
  • 6
  • 13
  • 25
    "Allow parallel run" means that the same run configuration can be repeatedly started, while previous incarnations are still running. This likely isn't what people are looking for when they are trying to get their tests to run concurrently - this allows them to the same test set in parallel, but doesn't allow for individual tests to be running concurrently. – dan.m was user2321368 Dec 04 '19 at 19:21
  • 12
    The fork mode setting on Intellij does not result in concurrent test execution. It does start a new JVM for tests which increases test latency; but, it will clear out memory between tests which can be a problem for applications that use singleton classes or other long lived classes. – Scott Boring Jan 01 '21 at 00:31
  • 3
    I don't think this results in parallel text execution, for me it even slows down test execution by a factor of 5x. I think forked mode is meant to be used to run tests separately in different JVMs, but not to speed up test execution!! – Nfff3 Jan 31 '21 at 10:08
6

UPDATE in 2022: This plugin lets you run and debug tests in parallel in IntelliJ IDEA with JUnit4, JUnit5 and TestNG: https://plugins.jetbrains.com/plugin/16229-unit-test-parallel-runner


If you are using JUnit4, you can give this plugin a try: https://plugins.jetbrains.com/plugin/12959-junit4-parallel-runner

Running tests in parallel is as easy as clicking on the green triangle next to a

  • class -> all the test methods in the class are run in parallel
  • package -> all the classes in the package are run in parallel
Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
Csa77
  • 649
  • 13
  • 19