• 21 September

    [Fixed] Org.Mockito.Exceptions.Misusing.WrongTypeOfReturnValue

    In this post, we will see how to fix Org.Mockito.Exceptions.Misusing.WrongTypeOfReturnValue. There are two major reasons because of which you can get this Exception. These details are provided in Exception itself. This exception might occur in wrongly written multi-threaded tests. Please refer to Mockito FAQ on limitations of concurrency testing. A spy is stubbed using when(spy.foo()).then() […]

  • 17 September

    Mockito Mock static method

    In this post, we will see about Mockito Mock static method. If you want to mock static methods, you need to use PowerMockito.PowerMockito is capable of testing private, final or static methods as it makes use of Java Reflection API. Let’s create a simple example to mock static method using powermockito. 1. Create a simple java […]

  • 17 September

    Mockito Mock Example

    In this lesson with Mockito, we will learn what is at the core of Mockito, which surprisingly is, mocks! Mock is an object that has predefined answers to method executions made during the test and has recorded expectations of these executions. Steps for creating Mockito TestNG example. Step 1: Create a simple java maven project. […]

  • 16 September

    PowerMock tutorial

    1. Overview Mockito is a powerful, open-source Mocking framework in Java. The features it provides for unit-testing is inevitably unique and important, nonetheless, ease out a lot of work for developers while writing unit test cases. While Mockito can help with virtually everything, there are some things it cannot do. Like stubbing or testing private, final […]

  • 16 September

    Using Mockito with TestNG

    TestNG is an open source automated testing framework which is meant to perform unit, functional, end-to-end, integration testing. TestNG need minimum Java JDK 5. Based on the website, TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use like Annotation, Support […]

  • 16 September

    Using Mockito with JUnit

    In this lesson with Mockito, we will use another framework for complete testing, known as JUnit. According to JUnit website, JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. With Mockito, creating mock objects is very easy. It provides many simple annotations to […]

  • 11 September

    Mockito Spy example

    In this lesson on Spy in Mockito, we will see how Spies differ from Mocks and how are these used. Adding to classpath, using Maven The fastest way to add Mockito to your project is using Maven dependency. [crayon-662bc540e3c65759173106/] This dependency is simple enough and does not bring any additional or redundant libraries. See here for […]

  • 09 September

    Mockito Example with Best Practices

    In this lesson, we will study Mockito, a full fledged framework in Java to create test doubles or mocks. Introduction Mockito is an Open Source Mocking framework in Java and provides easy ways to create test doubles, also referred to as mocks in further writing. In Mockito, we mock behavior, not implementation by adding a dummy […]