Latest post from this blog

How to Manage Test Execution Across Different Browsers and Environments (QA, UAT, Staging)

In real-time automation projects, test execution is never limited to a single browser or a single environment . Applications must be validated across multiple browsers (Chrome, Firefox, Edge) and multiple environments such as QA, UAT, and Staging before going live. A well-designed Selenium + Java + Cucumber automation framework should allow testers to switch browsers and environments easily without changing test scripts . This blog explains how to manage test execution efficiently across different browsers and environments using best practices followed in real projects. Why Multi-Browser and Multi-Environment Testing Is Important Different users use different browsers QA, UAT, and Staging environments have different configurations Bugs may appear only in specific environments or browsers Same test cases must be validated everywhere before production release Common Challenges Testers Face Hardcoded browser names and URLs Maintaining separate test scripts for each environment Browse...

Understanding the TestNG XML Configuration File for Controlling Test Execution

Introduction

TestNG configuration file (TestNG.xml). This file is used to configure and control the execution of tests in TestNG, a testing framework for Java. Here's a breakdown of its purpose:  

TestNG.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Cucumber with TestNG Test">
<classes> package.ClassName
<class name="package.ClassName"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Example package.ClassName--> com.abc.abc.selenium.cucumberoptions.TestNGTestRunner

Key Components of Testng.xml 

1. <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">: This line is the document type declaration. It defines the rules for the markup language, so the browsers can render the content correctly.  

2. <suite name="Suite">: This line starts a TestNG suite. A suite is a collection of test cases that can be tested together. The name attribute is used to give a name to the suite.  

3. <test name="Cucumber with TestNG Test">: This line starts a TestNG test. A test is a collection of test methods. The name attribute is used to give a name to the test. 

4. <classes>: This tag is used to specify the classes that contain the test methods.  

5. <class name="com.siemens.sinecams.selenium.cucumberoptions.TestNGTestRunner"/>: This line specifies a class that contains test methods. The name attribute is the fully qualified name of the class. In this case, the class is TestNGTestRunner which is located in the package com.siemens.sinecams.selenium.cucumberoptions.  

6. </classes>, </test>, </suite>: These lines are closing tags for the classes, test, and suite elements, respectively.

Conclusion

TestNG XML configuration file (testng.xml) is important for managing tests in the TestNG framework. It helps you organize your tests, set their order, group them, and pass parameters easily.

Using testng.xml, you can create a clear structure for your testing process. It also allows for added features like listeners and parameters, which improve reporting and customization.

By trying out testng.xml, you can enhance your testing approach and make automation more effective. We encourage you to explore TestNG and its features. Happy testing!

Comments

Popular posts from this blog

How to Manage Test Execution Across Different Browsers and Environments (QA, UAT, Staging)

Purpose of the StepData Class in Selenium + Java Cucumber Automation Framework

Ensuring Thread Safety in Parallel Test Execution with Selenium, Cucumber, and Java