Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Mockito Zero to Hero : Complete Crash Course
Rating: 5.0 out of 5(1 rating)
3 students

Mockito Zero to Hero : Complete Crash Course

Learn JUnit 4 & 5, Mockito 3, Mocking, Stubbing, Test Doubles, Behavior Verification, BDD, ArgumentCaptor & Matchers.
Last updated 12/2025
English

What you'll learn

  • Understand the fundamentals of Unit Testing in Java.
  • Learn and implement different Test Doubles: Fake, Dummy, Stub, Mock, and Spy.
  • Set up Java projects with JUnit 5 and JUnit 4 using Maven.
  • Master Mockito 3 for creating mocks, stubs, and spies.
  • Use Mockito annotations, extensions, and runners for efficient testing.
  • Apply stubbing techniques including when(), thenReturn(), doReturn(), and void methods.
  • Handle common Mockito misuse and exceptions like UnfinishedStubbingException and PotentialStubbingException.
  • Perform behavior verification to ensure correct interactions with mocks and spies.
  • Use ArgumentCaptor and Argument Matchers effectively for real-world test scenarios.
  • Apply BDDMockito and Behavior-Driven Development practices in unit tests.

Course content

12 sections55 lectures6h 58m total length
  • Introduction to Unit Testing8:49
  • Introduction to Test Doubles4:48

Requirements

  • Basic knowledge of Java programming.
  • Understanding of object-oriented concepts in Java.
  • A working Java development environment (JDK, IDE like Eclipse/IntelliJ, Maven).
  • No prior experience with Mockito or JUnit is required — beginners are welcome.

Description

Great Unit Tests turn good developers into exceptional developers.
And nothing strengthens your Java testing skills more than mastering JUnit and Mockito together.

In this course, you will learn Real-World Java Unit Testing from the ground up — starting with the fundamentals of Unit Testing and Test Doubles, all the way to advanced mocking, stubbing, behavior verification, BDD, ArgumentCaptor, Argument Matchers, and much more.

This course is designed to take you from absolute beginner to confident professional in a clear, simple, and hands-on way.

Whether you’re preparing for a job interview, writing tests at work, or improving code quality in your projects — this course will give you all the skills you need.

What You Will Learn

  • Learn Unit Testing with clarity and simplicity

  • Understand all types of Test Doubles (Fake, Dummy, Stub, Mock, Spy)

  • Master Mockito from basics to advanced usage

  • Write clean, structured, professional tests

  • Avoid common Mockito mistakes and misuse

  • Build confidence to work in real industry-level Java projects

  • Learn both JUnit 5 and JUnit 4 setups

  • Apply Behavior-Driven Development (BDD) with Mockito

This course is structured in a practical, step-by-step teaching style, ensuring every concept is clearly explained, demonstrated in code, and reinforced with examples.

Course Highlights

You will progress through multiple stages of Mockito and JUnit mastery — starting with theory, then applying each concept in real Java code.

Unit Testing Foundations

  1. Introduction to Unit Testing

  2. Introduction to Test Doubles

  3. Maven Setup with JUnit 5

Test Doubles Without Mockito

  1. Fake Test Double

  2. Dummy Test Double

  3. Stub Test Double

  4. Spy Test Double

  5. Mock Test Double

Project Setup

  1. Project setup with JUnit 5 and Maven

  2. Project setup with JUnit 4 and Maven

Mockito Essentials

  1. What is Mocking?

  2. Introduction to Mockito

  3. Creating Fake, Dummy, Stub, Mock, and Spy using Mockito

  4. Creating Mocks using Annotations

  5. Mockito Extension (JUnit 5)

  6. MockitoJUnitRunner (JUnit 4)

  7. MockitoAnnotations.initMocks

  8. Mockito Rule

Stubbing Methods

  1. What is Stubbing?

  2. Stubbing with when() and thenReturn()

  3. Stubbing with doReturn() and when()

  4. Stubbing multiple calls of the same method

  5. Stubbing void methods

Mockito Misuse (Real-World Errors)

  • UnfinishedStubbingException

  • PotentialStubbingException

You will learn exactly why these errors happen and how to fix them.

Behavior Verification

  1. Verify simple interactions

  2. Verify number of method invocations

  3. Verify no interactions

  4. Verify order of interactions

  5. Verify min/max invocation count

Exception Handling

  1. Exceptions in non-void methods

  2. Exceptions in void methods

ArgumentCaptor

  1. ArgumentCaptor without annotations

  2. ArgumentCaptor using annotations

Spy Deep Dive

  1. What is Spy in Mockito?

  2. Spy using annotations

  3. Stubbing a Spy

  4. Verifying Spy behavior

Behavior-Driven Development (BDD)

  1. Introduction to BDD

  2. Stubbing with BDDMockito

  3. Behavior verification with BDDMockito

  4. Exception handling in BDD

Argument Matchers

  1. Introduction to Matchers

  2. Type Matchers

  3. Specific Type Matchers

  4. Collection Matchers

  5. String Matchers

  6. Common Matcher Misuse

Why This Course?

  • Covers everything from basics to advanced Mockito usage

  • Real project scenarios and examples

  • Clear explanations and step-by-step approach

  • Both JUnit 4 and JUnit 5 covered

  • Includes BDD, verification, argument capturing, and exception handling

  • Ideal for beginners, students, and working professionals

Start Learning Now

Enroll today and begin your journey toward becoming a confident, highly skilled Java tester using JUnit and Mockito.

Who this course is for:

  • Java developers who want to master unit testing.
  • Software engineers preparing for technical interviews involving testing.
  • Beginners who want to learn JUnit 5, JUnit 4, and Mockito from scratch.
  • Professionals looking to improve code quality through effective unit tests.
  • Developers interested in BDD, behavior verification, and advanced mocking techniques.