A multi-module Maven project is one that manages a group of submodules and is built from a parent POM. Submodules are normal Maven projects and can be built independently or from the main POM.
The main POM is located in the root directory of the project. We can include all the configurations with dependencies in the main POM file which can be used in multiple submodules because the submodules inherit everything from the main POM file. In addition to inheritance, Maven also provides the notion of aggregation. This POM also declares its submodules explicitly in its pom.xml file.
Submodules or subprojects are regular Maven projects that inherit the configuration and dependencies of the parent POM. Each submodule also declares its parent module explicitly in its pom.xml file. The main difference between the main multi-module POCT and the normal POM is the type of packaging. For a multi-module parent pom, the packaging type is “pom”.
Application and benefits of using multiple modules in a test automation framework
Real-life applications are built as a result of multiple layers, not just built with the UI, API, or data layer. From the development point of view, any application consists of at least 3 components: data layer; Web services; Web Application.
From a test automation standpoint, most companies have frameworks for different types: API automation; website automation; mobile automation. So we can take advantage of a multi-module structure for building our automation framework to have all kinds of automation tests in a single repository.
- A single command is needed to build all projects, including submodules.
- Define common dependencies in the main POM; which will be implicitly inherited by all submodules.
Test Ex NG; log4j; The apache-commons dependencies can be added in the Parent POM; and can be used in all submodules without redeclaring in the submodules’ POM files.
- Helper classes/Utilities etc. they can be written to one of the modules; and can be used directly in other modules. It leads to less code duplication and makes code refactoring easier.