Home » mockito

Tag Archives: mockito

How to use Spies in Mockito

Hello. In this tutorial, we will understand Spy in Mockito. As stubbing is now obsolete I will focus @Spy annotation in this tutorial. 1. Introduction Mockito is a popular framework used to mock the interfaces or classes so that dummy functionality can be added during the unit testing. It is a java based library that helps simplify the test-cases development ...

Read More »

Spring Boot MockMVC Tutorial

In this article, we provide a tutorial about Spring Boot MockMVC. 1. Introduction As a software developer, you need to validate that your code is working correctly. You accomplish this by testing. There are different types of tests: Unit tests target a specific section of code, such as a methodIntegration tests verify that the interactions between your code and other ...

Read More »

JUnit Mockito When thenReturn Example

In this example we will show you the usage of JUnit Mockito When thenReturn method. JUnit has many capabilities for testing the unit test cases for Java. But sometimes it lacks some of the common functionalities. Where it lacks and how we can complete, we will be showing in this example. First of all, we have to be aware of ...

Read More »

Mockito Mock Database Connection Example

A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. In this example we will learn how to write a simple test case using Mockito. Tools and technologies used in this example are Java 1.8, Eclipse ...

Read More »

Mockito List Matcher Example

In the Mockito Tutorial for Beginners, we saw a general overview of the use of Mockito framework for Java unit tests. In this example,we will see how are and how to use the Mockito Matchers for List elements. For this example, we will use: Java 1.7.0 Eclipse Mars 2, release 4.5.2. JUnit 4. Mockito 1.10.19. Tip You may skip project ...

Read More »

Mockito Test Case Example

A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. In this example we will learn how to write a simple test case using Mockito. Tools and technologies used in this example are Java 1.8, Eclipse ...

Read More »

Test-Driven Development With Mockito

In this example we will learn how to do a Test Driven Development (TDD) using Mockito. A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. Tools and technologies used in this example are Java 1.8, ...

Read More »

Writing JUnit Test Cases Using Mockito

In this example we will learn how to write JUnit tests using Mockito. A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. Tools and technologies used in this example are Java 1.8, Eclipse Luna 4.4.2 ...

Read More »

Mockito Maven Dependency Example

A unit test should test a class in isolation. Side effects from other classes or the system should be eliminated if possible. Mockito lets you write beautiful tests with a clean & simple API. In this example we will learn how to define Mockito dependency in maven and how to use it. Tools and technologies used in this example are ...

Read More »

JUnit Mockito Example

1. Introduction Methods and ways to create Unit Test cases have evolve ever since it’s introduction. New tools and API´s are now available and they provide a more advanced scheme on creating and executing JUnit Test cases. Services have become more incubated, so creating integration test cases has been a daunting task for any developer. The introduction of this new ...

Read More »