3

I have some long running JUnit tests which I want to run first to avoid them being queued and executed last and thus delaying the whole test execution process.

I currently use maven surefire to run my tests using:

  • forkCount: 5
  • reuseForks: false

Is there a way to specify which tests should be run first? Or a way to optimize the order in which the tests are run?

The runOrder=balanced parameter does not seem to work in combination with forkCount > 0 and reuseForks false.

Jotschi
  • 3,270
  • 3
  • 31
  • 52
  • A specific order needed for unit tests shows that you don't have unit tests which are by definition wrong...Those tests are integration tests which should be done by TestNG and maven-failsafe-plugin instead... – khmarbaise Feb 09 '17 at 21:02
  • Don't get confused by the initial title. I want to run the unit tests in the optimal order to save execution time. I updated the title. – Jotschi Feb 10 '17 at 21:21

1 Answers1

0

Unfortunately, you can’t determine the test execution order. Here is a clumsy workaround for this problem. For integration tests, I use a JUnit extension to run tests in specific order.

Community
  • 1
  • 1
Patrick
  • 447
  • 8
  • 17
  • For integration tests I would always use TestNG instead of JUnit cause TestNG has dependencies which is needed sometimes in integration tests... – khmarbaise Feb 09 '17 at 21:02