Latest post from this blog

Test Scenarios vs. Test Cases: Understanding the Basics

What Are Test Scenarios Test scenarios represent high-level ideas or conditions that need to be validated to ensure the application works as expected. They provide a broader perspective and are typically used during the test planning phase. Purpose: To capture the "what to test" without going into granular details. Example of a Test Scenario: Verify that a user can successfully log in to the application using valid credentials. Verify the behavior of the login page when invalid credentials are entered. Verify the application behavior when the login button is clicked without entering any credentials. What Are Test Cases Test cases are detailed documents that define the specific steps to execute a test. They cover inputs, execution steps, expected results, and actual outcomes. Purpose: To guide the tester step-by-step on "how to test." Example of a Test Case (for the first scenario): Test Case ID TC_01_Login_Valid_Credentials Test Scenario Verify user login with val...

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

Common Exception in Selenium

Test Scenarios vs. Test Cases: Understanding the Basics

Handling Shadow DOM in Selenium WebDriver

Handling HTTPS Websites and SSL Certificate Errors in Selenium

Normalize-space Function In Xpath