EasyMock TestNG Example

In the EasyMock Tutorial, we used it with JUnit 5. In this tutorial, we will learn how to integrate EasyMock with TestNG testing framework.

EasyMock TestNG Example

We will build up our EasyMock TestNG example from the earlier tutorial. First of all, we will have to add the TestNG dependency to the already existing EasyMock example project.

Here is a simple example where I am mocking ArrayList and stubbing its behaviors. Then I am using TestNG assertions to write some test cases.

EasyMock TestNG Annotations Example

Let’s look at another example where I will use EasyMock annotations with TestNG annotations.

Summary

EasyMock integrates very easily with the TestNG framework just like JUnit. Actually, it’s very easy to switch between TestNG and JUnit while working with the EasyMock mocking framework. All we need is to change few import statements for assertions and testing lifecycle and callback methods.

You can checkout complete project and more EasyMock examples from our GitHub Repository.

By admin

Leave a Reply

%d bloggers like this: