Unit Test your Test Automation Framework with Mockito

By: Slav Kurochkin

When testing financial application you most likely going to interact with dates, some rules would happen after another, or when deadline has passed, I bet you would perform some calculation based on a given information and set appropriate values.

By saying all of those things I assume you already abstracted most of your methods, which is performing all dirty work for your UI Automation Framework. Then I would call your Test Automation Framework an application which require unit tests of your methods, mocking objects and data, that is where Mockito is appearing on a scene, it is Java based testing framework which allow you to mock objects and provide you an options to return values you need in order to complete your unit tests on a green line.

In order to start using Mockito add dependency to your pom.xml file, or simply add jar file to the framework.


The thing I like about Mockito, it is consistent with BDD approach I'm trying to use in our Test Automation Framework, for example you can find a good use of when/then conditions.

And of cause you wouldn't have problems to integrate your tests with existing test runners, in our case we use JUnit.

    private DatesHelper mock;

    public void setUp() {

    private static String month = "01";
    private static String day = "01";
    private static String year = "2015";
    private static String date = "01/04/2015";

    public void threeDaysAfterCalendarTest() {
        assertEquals("01/04/2015", mock.getThreeDaysAfterCalendar(month, day, year));
View Comments

Leave a Comment

Use markdown or basic HTML and be nice.