Maven - Build Tool - Invocation of JUNIT & TESTNG from POM (Project Object Model)

11:53 PM 0 Comments






Maven is a build automation tool. From Selenium perspective we should be mainly understanding the following sections of the POM (Project Object Model)

1. DEPENDENCIES : 
           Selenium Web-driver mainly depends on  jar for compilation and execution of program. Also if we implement Java Framework - TESTNG / JUNIT, we need add the dependencies for TESTNG / JUNIT as well. Also dependencies gives you the information, that what is the version of the jar we are using for compiling and executing the program.
Also, all the required jars are downloaded into the folder c:\\users\.m2 folder.
.m2 folder is repository folder created by maven, used for referring to the jars required for compilation and execution of program.

SELENIUM DEPENDENCIES:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
REFERENCE:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
REFERENCE:
http://mvnrepository.com/artifact/org.testng/testng/6.8.8

JUNIT DEPENDENCIES:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
REFERENCE:
http://mvnrepository.com/artifact/junit/junit/4.4       
         
2. PLUGINS

Plugins helps to execute the JUNIT/TESTNG programs to execute.
Also in case of JUNIT we have to include Suite class. And in the case of TESTNG we have to include the testng.xml file.

JUNIT PLUGIN INFORMATION
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.surefire</groupId>
        <artifactId>surefire-junit47</artifactId>
        <version>2.18.1</version>
      </dependency>
    </dependencies>
    <configuration>
<includes>
            <include>JunitTestSuite.java</include>
          </includes>
    </configuration>
</plugin>
REFERENCES
http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

TESTNG PLUGIN INFORMATION:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.surefire</groupId>
        <artifactId>surefire-junit47</artifactId>
        <version>2.18.1</version>
      </dependency>
    </dependencies>
    <configuration>
<includes>
            <include>testng.xml</include>
          </includes>
    </configuration>

</plugin>
REFERENCES:
http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html

Unknown

This site creates a platform to become an expert by gaining knowledge of unknown real-time issues as well.

0 comments: