O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Assertion with TestNG

Assertion plays an important part while performing unit testing. Assertion helps you to check or verify the success of conditions in your test. If the conditions don’t satisfy, it will stop the test execution of the said test and mark it as failing.

Assertions are basically code blocks that can be placed in test cases to verify certain conditions. Most of the unit test frameworks provide implementations for using assertions in the tests. TestNG supports assertion of a test using the Assert class which is part of the library. The following table describes few of the methods and their usage that are available with the Assert class in testng:

Method

Usage

assertEquals(boolean actual, boolean expected)

Takes two Boolean arguments ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required