Blog Archives

01: JUnit with Mockito tutorial step by step

JUnit with Mockito tutorial step by step. Mockito is a popular mocking framework used along with JUnit. JMockit is more popular than Mockito.

Step 1: Create a simple maven project say “code-quality”

Step 2: Import into eclipse.…



02: Unit testing with JUnit, Mockito & Spring

Step 1: Create a simple Maven project from a command-line. Just press enter for all the prompts.

Step 2: Import the above “simple-mocking-test” in the file system into eclipse.…



03: Mockito to fully mock the DAO layer

This extends Part 1: Unit testing with JUnit, Mockito & Spring by mocking the DAO layer with the Mockito framework. Step 1: Service and DAO layer interfaces and implementations Service…



04: Mockito partially mocking with @Spy

This extends Part 2: Mockito to fully mock the DAO layer by modifying the service layer to demonstrate partial mocking with “Mockito.spy”. In the “SimpleServiceImpl” we are interested in only…



05: Mockito & PowerMock partially mocking private methods with @Spy

This extends Part 3: Mockito partially mocking with @Spy by making the method “processUser(int id)” as a private method. Mockito framework cannot mock “private” methods, hence the “PowerMock” framework is…



06: Mockito & PowerMock for mocking static methods

This extends Part 4: Mockito & PowerMock for partially mocking private methods to mock “static” methods.

How to use both Spring JUnit and PowerMock runners?

By using the “@PowerMockRunnerDelegate” from the “powermock-module-junit4” jar.



800+ Java & Big Data Interview Q&As

200+ Java & Big Data Tutorials

Top