(Transcript) Chapter 6.1_ Intro To TestNG Assertions
(Transcript) Chapter 6.1_ Intro To TestNG Assertions
Chapter 6.1:
Introduction To TestNG
Assertions
Introduction
I have a question for you. Up to this point, what have we tested. We have automated Opening Chrome
and the application, signing into the application, searching for a user, signing out, closing chrome, and
closing the application. We have not verified our Test Script and not sure if it truly Passed or Failed. The
Console shows Passed and the Results tab shows all 3 Test Passed. However, it shows Passed because
there was no error in our automation code and no error when running our Automation Test Script. Let
me show you something else. I’m going to remove all code to search for a user then Run. The Test Script
did not search for a user but look what the Console shows PASSED: userSearch although Number 3
Search For User is missing. The Results tab also shows Passed for userSearch. That’s not right.
The main difference between JUnit’s class and TestNG’s class is the syntax. Their parameters are
available in reverse order. For example, the assertEquals method for JUnit has a String as the first
parameter followed by an expected result then an actual result. The same method for TestNG has actual
as the first parameter, expected as the second parameter then String as the last parameter.
Rex Jones II
Let’s go to Eclipse and I’ll show you the assertions. Go to the TestNG Library, maximize the TestNG jar
file, select org.testng package, and we see both classes: Assert and AssertJUnit class. Maximize Assert
and there’s a lot of methods. Maximize AssertJUnit and we some of the same overloaded methods. The
methods within our Assert class are considered Hard Asserts. In the next chapter, we will cover Hard
Asserts.