Mockito Tutorial: Learn mocking with 25 Junit Examples

Video description

Writing great unit tests distinguishes good programmers from great programmers. In this course, you will learn how to write great unit tests with Mockito and JUnit. You take 12 steps with JUnit and 18 steps with Mockito into unit testing proficiency.

What You Will Learn

  • Use Mockito to write great unit tests
  • Understand the basics of unit testing
  • Understand how to use JUnit and Mockito together

Audience

This course is for students who want to learn unit testing with JUnit. Students who want to learn mocking with Mockito. We will help you install Eclipse and Maven.

About The Author

In28Minutes Official: Ranga Karanam is a seasoned technologist and architect with over two decades of expertise in programming, design, and architecture. He founded in28Minutes with the goal of helping students master cutting-edge cloud-native technologies such as AWS, Azure, Google Cloud, Docker, and Kubernetes. With 15 years of experience in Java programming and design, Ranga has collaborated with top banking clients worldwide.

His passion for creating hands-on courses with real-world projects motivated him to develop the Step-By-Step series of courses that follow a problem-solution-based approach, with practical and real-world application examples.

Ranga and his team at in28Minutes specialize in Java and related frameworks such as Spring, Spring Boot, Spring MVC, Struts, and Hibernate. They are committed to equipping learners with the skills and knowledge necessary to succeed in today’s rapidly evolving technology landscape.

Table of contents

  1. Chapter 1 : Introduction
    1. Introduction
    2. Three thing you need to know
  2. Chapter 2 : Unit Testing with Junit
    1. JUnit Step 1: Why is Unit Testing Important?
    2. JUnit Step 2: Setting up your first Junit
    3. Step 03: First Successful JUnit. Green Bar and assertEquals
    4. Step 04: Refactoring Your First JUnit Test
    5. Step 05: Second JUnit Example assertTrue and assertFalse
    6. Step 06: @Before @After
    7. Step 07: @BeforeClass @AfterClass
    8. Step 08: Comparing Arrays in JUnit Tests
    9. Step 09: Testing Exceptions in JUnit Tests
    10. Step 10: Testing Performance in JUnit Tests
    11. Step 11: Parameterized Tests
    12. Step 12: Organize JUnits into Suites
  3. Chapter 3 : Getting Ready for Mockito
    1. An Overview
    2. Mockito Step 01: Setting up a Maven Project
  4. Chapter 4 : Need For Mockito
    1. Overview of this Section
    2. Mockito Step 02: Setting up SUT (System Under Test)
    3. Step 03: Stubbing Example - with Disadvantages of Stubbing
    4. Step 04: Your first Mockito code! Hurrah!!!
  5. Chapter 5 : Mockito Basics
    1. Basics of Mockito - Section Overview
    2. Step 05: Stubbing variations with Mockito - Argument Matchers More...
    3. Step 06: BDD Style - Given When Then
    4. Step 07: Verify calls on Mocks
    5. Step 08: Capturing arguments passed to a Mock
  6. Chapter 6 : Mockito Advanced
    1. Step 09: Hamcrest Matchers
    2. Step 10: Mockito Annotations - @Mock, @InjectMocks, @RunWith, @Captor..
    3. Step 11: Mockito Junit Rule
    4. Step 12: Real world Mockito Example with Spring
    5. Step 13: Mockito Spy
    6. Step 14: Theory: Why does Mockito not allow stubbing final private methods?
  7. Chapter 7 : Powermock with Mockito
    1. Step 15: Setting up PowerMock and SystemUnderTest
    2. Step 15: Continued. Mocking Static Method
    3. Step 16: Invoking Private Methods
    4. Step 17: Mocking a Constructor
    5. Step 18: Writing Good Unit Tests

Product information

  • Title: Mockito Tutorial: Learn mocking with 25 Junit Examples
  • Author(s): In28Minutes Official
  • Release date: February 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789135039