Its is been a long time since I am running away from this topics as frankly speaking I never thought the integration with build tool would any help to Automation Life cycle. I can not think of a scenario where build is happening and testers are not around On top of it there are good chances that your automation script will fail due to any number of reasons during the build process and I am sure that the developers would not be able to fix that for you. So conclusion is that when the testers are present during the build time then why dont just wait for the build & deployment and start the automation suite manually.
People who are interested in Maven for Selenium, let me just warn them that only using Maven would not have any significance in Selenium life. This tool has to integrate with Jenkins as well to give any benifits to Selenium Automation. You may face N number of issues with installing and in setting up Maven & Jenkins which would be difficult to resolve, as we as Test Enginners are not very technical. Please be calm and read out every line and word of this tutorial to understand it else you would end up with lots of frustration.
What is Maven?
Maven is a build tool and it performs task just like Ant which is again a diffirent build Tool. It is a software project management tool which provides new concept of project object model (POM). Maven allows the developer to automate the process of the creation of the initial folder structure, performing the compilation and testing and the packaging and deployment of the final product. It cuts down the good number of steps in build process and it makes it one step process to do a build.
Why Maven is Used?
As I siad above it cuts down the tasks in build process. To summarize, Maven simplifies and standardizes the project build process. It handles compilation, distribution, documentation, team collaboration and other tasks seamlessly. Maven increases reusability and takes care of most of build related tasks. It helps in bypassing my steps like adding jars to the project library, building reports, executing Junits test cases, creating Jar, War Ear files for the project deployment and many more. A very significant aspect of Maven is the use of repositories to manage jar files.
Few Glossaries around Maven
Maven Local Repository
This is the place where Maven stores all the project jars files or libraries or dependencies. By deault the folder name is ‘.m2‘ and by default the location in windows 7 is ‘Libraries\Documents\.m2‘.
Maven Central Repository
Maven central repository is the default location ‘http://mvnrepository.com/‘ for Maven to download all the project dependency libraries. Fo any library required in the project, Maven first look in to the .m2 folderof Local Repository, if it does not find the required libarary then it looks in Central Repository and download the libabry in to local repository.
Dependencies are the libararies, which are required by the project. For example Log4j jars, Apache Poi jars, Selenium Jars etc. Dependencies are mentioned in the Maven pom.xml like this:
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in 2 different file formats like plain text file, xml files and html files as well. Even if you are using TestNG or Junits framework for reporting, this plugin is must to use, as it helps Maven to identify tests.
POM is Project Object Model XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects. Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on.