POM.XML
POM is an XML file which contains the project configuration details used by Maven. It providesall the configuration required for a project. POM means project object model, and, as the name
suggests, it defines the model of the project as well
Maven
Maven is a powerful project management tool that is based on POM (project object model).
It is used for projects build, dependency and documentation.
How to Create Maven project
Step1- Goto File-->New--> Select Maven project or other.
Click on other
Step2- On click of other from above screen, you will get below new window.
Type “Maven” in wizard text box. Maven project option will appear.
Click on Next button.
Step3 – on click of next button from above screen, you will navigate to below page. Click on “Create simple project” check box.
Click on “Next” button.
Step 4-On click of “Next” button from above screen. You will get below window to update group Id and Artifact Id. Mention any Group id and Artifact Id as shown in below screen shot.
Click on finish
Sept 5- On click of above finish button, your maven project will get created, as shown in below screen shot.
src/mail/java- This part is used for writing page xpath and program logic. You can create class for all the and their xpath detail in this part.
Src/text/java- This part can be used for writing actual script or Test annotation to run the test case.
Src/main/resources- This part can be used for data and other values which can be pass as parameter in your program, such as test data, environment detail, etc.
Src/main/resources- Same as above.
Pom.xml- This contains your all dependencies and profile mapping.
Pom.xml File
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>ParameterPro</groupId> <artifactId>ParameterPro</artifactId> <version>0.0.1-SNAPSHOT</version><!-- Below profile name is mentioned--> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <suiteXmlFiles> <suiteXmlFile>NewFile.xml</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin> </plugins> </build><!-- Below dependency is given--> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.8</version> <scope>test</scope> </dependency> </dependencies></project>
Java class
public class ParaPass {
@Test @Parameters({"name","Sirname","Age"}) public void test(String name, String lastname, int age) { System.out.println(name); System.out.println(lastname); System.out.println(age); }}
NewFile.xml file
<suite name="paramerProgram"><test name="newParamer"><classes><class name="NewProgram.ParaPass"/></classes></test></suite>
Parameter passed in goal, see below screen shot.
When we run program from goal, it will read pom.xml and execute “NewFile.xml”file.
And the parameter mentioned in goal will pass to Java class
Out put-
No comments:
Post a Comment