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

Mocking with TestNG

TestNG don’t have an inbuilt mocking implementation in it, but we can use any third-party implementations that are based on Java; and which don’t rely on a particular kind of unit test execution framework to be used along with it. You had already read about mocking and different mocking techniques that are available in the market. In this section we will take two of the most commonly used mocking frameworks Jmock and Mockito, and write sample programs using them in TestNG.

Jmock

Jmock was one of the initial mocking frameworks that were developed to support unit testing and TDD based development approach. It provides all the basic features required for mocking, such as mocking objects, methods, return values and so on. It was ...

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