Search code examples
javamavenunit-testingantmulti-module

Is good pratice create a project maven module specific for tests?


I have a ANT project and I'm migrating to maven. This project has some src folders and for each src folder I decided to create a maven module project.

The problem is that each src folder has unit tests and at build all classes are compiled in a classes folder, so all the dependences between tests are resolved.

Creating maven modules, one module do not recognize the dependencies between modules.

I thought about creating a maven project specific for tests. Is this a good pratice or there is another way?


Solution

  • Usually, a Maven project has a src/main and a src/test folder, and you put the unit tests for the project into the src/test folder.

    If your tests need additional dependencies, you can declare them with test scope in your pom.