Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

When to use testng.xml and maven profile?


Asked by Marcellus Dunlap on Dec 13, 2021 Maven



For example, the whole regression suite features are described in one testng.xml and sanity test cases are described in the other testng.xml file. In a situation like this, we need to use the profile concept in Maven.
And,
How to run testng.xml from maven 1 Write TestNG Tests. Below are two tests which we have already written in two previous tutorials. ... 2 Write TestNG Suite. Let’s see the testng suite files testng.xml and suites-test-testng.xml for both tests. 3 Add testng suites in maven. Add below pom.xml in project root. ... 4 TestNG maven example. ...
Just so, Here, execution starts from the Maven project using POM.xml. Initially, it connects to the Maven Online Repository and downloads the latest version of the dependencies. As TestNG has the capability to select and execute particular test scripts or suites, we are integrating this with Maven using the Maven Surefire plugin.
In fact,
What Is TestNG.xml? TestNG.xml file is a configuration file that helps in organizing our tests. It allows testers to create and handle multiple test classes, define test suites and tests. It makes a tester’s job easier by controlling the execution of tests by putting all the test cases together and run it under one XML file.
Thereof,
Step 1: First create a maven project and name it as 'FirstDemo'. Step 2: Create a class 'GoogleHomePageTest.java'. Step 3: Add Tests in 'GoogleHomePageTest.java' class. Step 4: Add TestNg and Selenium Dependencies to maven pom.xml file. Step 5: Now add maven Surefire Plug-in to pom.xml. Step 6: Execute tests using 'mvn test' from command prompt.