Book Image

TestNG Beginner's Guide

By : Varun Menon
Book Image

TestNG Beginner's Guide

By: Varun Menon

Overview of this book

<p>Unit/Functional testing has now become part of every development life cycle. Junit was once the main framework that was used by developers for the purpose of Unit testing when it came to Java. But Junit had certain limitations in terms of execution and features. This book explains about the features and usage of TestNg, a new framework that overcomes Junit’s limitations and provides a lot of extra features.</p> <p>TestNg Beginner’s Guide is a practical, hands-on guide that aims to increase your knowledge of TestNg. This step-by-step guide will help you to learn and understand the different TestNg features, and you will learn about the advantages and how to use and configure each feature according to your needs. <br /><br />This book explains the various features of the TestNG testing framework. It provides a step-by-step guide that explains the different features with practical examples and sample programs.You will also learn about how to use and configure each feature based on different test scenarios. We will also take a look at extending TestNG to add custom logging and test-reports. If you are a beginner in TestNG or test frameworks, then this book will help you in learning, practising, and getting started with TestNg.</p>
Table of Contents (21 chapters)
TestNg Beginner's Guide
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Features of TestNG


Now that you are at least a little familiarized with TestNG, let's go forward and discover more about the features offered by TestNG. The following are a few of the most important features:

  • Multiple Before and After annotation options: TestNG provides multiple kinds of Before/After annotations for support of different setup and cleanup options.

  • XML-based test configuration and test suite definition: Test suites in TestNG are configured mainly using XML files. An XML file can be used to create suites using classes, test methods, and packages, as well as by using TestNG groups. This file is also used to pass parameters to test methods or classes.

  • Dependent methods: This is one of the major features of TestNG where you can tell TestNG to execute a dependent test method to run after a given test method. You can also configure whether the dependent test method has to be executed or not in case the earlier test method fails.

  • Groups/group of groups: Using this feature you can assign certain test methods into particular named groups and tell TestNG to include or exclude a particular group in a test.

  • Dependent groups: Like dependent methods, this feature allows test methods belonging to one group being dependent upon another group.

  • Parameterization of test methods: This feature helps users to pass parameter values through an XML configuration file to the test methods, which can then be used inside the tests.

  • Data-driven testing: TestNG allows users to do data-driven testing of test methods using this feature. The same test method gets executed multiple times based on the data.

  • Multithreaded execution: This allows execution of test cases in a multithreaded environment. This feature can be used for parallel test execution to reduce execution time or to test a multithreaded test scenario.

  • Better reporting: TestNG internally generates an XML and HTML report by default for its test execution. You can also add custom reports to the framework if required.

  • Open API: TestNG provides easy extension of API, this helps in adding custom extensions or plugins to the framework depending upon the requirement.

We will discuss these features in more detail in coming chapters.