SELENIUM BASICS:


SELENIUM WEBDRIVER:


TESTNG:


REPORTS:


BUILD & CONTINUOUS INTEGRATION TOOLS:


CROSS BROWSER TESTING:


MOBILE TESTING:


AUTOMATION FRAMEWORKS:


API Testing:


INTERVIEW QUESTIONS:


SAMPLE RESUME:

TestNG Exception | TestNG Tutorial

TestNG Exception:

In this post, I will show how to use TestNG Exception (i.e., expectedExceptions) parameter along with the @Test annotation. TestNG provides an option of tracing the exception handling of code.

Firstly, we see a basic program without using TestNG Exception.

Created a java class, say, TestNGException.java and added an error condition in the method testException().

testng.xml:

Console Output:

As you can see from the test results, testException() method was marked as failed by TestNG during execution.

Now let’s see TestNG Exception in action.

Check below video to see “TestNG Exceptions”

Please be patient. The video will load in some time.

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

The expected exception to validate while running the below test is mentioned using the expectedExceptions attribute value while using the @Test annotation.

testng.xml:

Console Output:

As you can see from the test results, testException() method was marked as passed by TestNG during execution.

You could find the complete TestNG tutorial here.

TestNG Complete Tutorial

If you are not regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

Get our latest blog posts delivered to your inbox

Subscribe and get popular blog posts about software testing industry.

Rajkumar

Leave a Comment

Share via
Copy link
Powered by Social Snap