0

With Maven 3 it`s possible to build Projects with multiple Threads, like

mvn -T 4 clean install

Since we have Unit-Tests setting up on a consistent Database (and manipulating the data during execution), we need to make sure, that these Unit Tests are not running in parallel execution. I know that there is a configuration-option for Maven-Surefire-Plugin to execute Tests sequentially or enable parallel execution:

<configuration>
   <parallel>classes</parallel>
</configuration>

When I leave this configuration empty Tests should be executed sequentially, right? But is execution still sequentially when calling the Build with multiple Maven-Threads (-T) like above?

heinkunibert
  • 361
  • 2
  • 5
  • 15

2 Answers2

1

As far as I understand and from the documentation, parallel build runs modules in parallel and not the goals within each module. That being the case, the unit tests in a module will run sequentially unless configured in surefire to run in parallel.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • Thx for your response. But what means "...runs modules in parallel"? Isn't it neccessary to execute a goal on each module (in parallel) to "run a module"? – heinkunibert Jan 18 '12 at 08:44
  • @heinkunibert. Indeed. That is exactly what maven would do when it runs. – Raghuram Jan 18 '12 at 09:17
  • But if Maven executes goals on seperate modules in parallel the execution of unit-test within a project isn`t sequential anymore, no matter how I configured surefire-plugin. Seems that I can`t take advantage of threaded Maven Builds as long as I want sequential execution of Unit-Tests, right? – heinkunibert Jan 18 '12 at 10:06
  • @heinkunibert. a maven module is a separate maven project, and not a part of a project build. As such, parallel execution is relevant in multi-module projects and not for a single project. – Raghuram Jan 18 '12 at 10:20
  • sorry, when talking of a project I meant a multi-module project for sure ;-). – heinkunibert Jan 18 '12 at 11:04
0

I think what you're looking for might be here. It's about how surefire forks and or runs parallel threads.

Community
  • 1
  • 1
wilson
  • 163
  • 1
  • 2
  • 12