• Professional Development
  • Medicine & Nursing
  • Arts & Crafts
  • Health & Wellbeing
  • Personal Development

Course Images

JUnit and Mockito Unit Testing for Java Developers

JUnit and Mockito Unit Testing for Java Developers

  • 30 Day Money Back Guarantee
  • Completion Certificate
  • 24/7 Technical Support

Highlights

  • On-Demand course

  • 2 hours 56 minutes

  • All levels

Description

From installation and project creation to writing tests with JUnit, Mockito, and Hamcrest, this course will cover all the important concepts that you need to get up and running with unit testing.

Are you looking for a simple, no-nonsense guide to learning how unit testing works? This video course is what you need. Complete with hands-on exercises and best practices, this guide will help you to understand JUnit and Mockito unit testing with ease.
The course starts with an introduction to unit testing and highlights the need and importance of its testing framework, JUnit. You'll then understand the project structure and conventions by creating a Java project using JUnit. As you implement best practices for writing and running unit tests with JUnit and IntelliJ IDEA, you'll discover how JUnit works. You'll also write mock objects-based unit tests with Mockito for testing a simple layered architecture. Finally, you'll learn to make more powerful assertions in your unit tests by harnessing the power of the Hamcrest assertions library that ships with JUnit.
By the end of this course, you'll have developed the skills needed for writing better unit tests using JUnit, Mockito, and Hamcrest.
"All the resources and support files are available at https://github.com/PacktPublishing/JUnit-and-Mockito-Unit-Testing-for-Java-Developers

What You Will Learn

Understand modern unit testing concepts and best practices
Find out how to run unit tests in the IDE
Analyze production code for writing quality unit tests
Study and implement JUnit s fail fast mechanism
Become familiar with Mockito and mock objects
Compose Hamcrest matchers to create readable assertions

Audience

Whether you are a Java developer or a tester who wants to write unit tests using JUnit, Mockito, and Hamcrest, this course is for you. A basic understanding of Java is necessary to get started with this course.

Approach

This course offers a balance of theory and practical exercises to explain concepts in an easy-to-follow way. With the help of hands-on examples and simple language, this course makes learning unit testing and its tools a smooth and interesting action.

Key Features

Find out why JUnit is the best framework for writing unit tests * Get hands-on exercises of JUnit and Mockito in action * Get to grips with modern unit testing concepts and best practices

Github Repo

https://github.com/PacktPublishing/JUnit-and-Mockito-Unit-Testing-for-Java-Developers

About the Author
Matthew Speake

Matthew Speake is a Java technologist and trainer. He has over 20 years of experience working everywhere from small start-ups to large global corporations and is the principal trainer at Zention in the UK. He started JavaEasily in 2018 to produce courses focused on teaching Java technology to students all around the world. Since then, JavaEasily has been busy creating and publishing courses and articles on different aspects of Java to help beginners and intermediate Java developers enhance their skills. JavaEasily helps you become a better Java developer by teaching you the core skills you need in order to succeed in your Java career.

Course Outline

1. Introduction

1. Welcome to the Course

This video presents an overview of the course and introduces you to the outline of this course.

2. Overview of the Course Structure

This video provides an overview of the structure of the course.

2. Unit Testing Foundations

1. Section Introduction

This video outlines the concepts that will be covered in this section.

2. What is Unit Testing?

This video explains what is unit testing and its basics concepts.

3. What is JUnit?

This video provides an overview of the JUnit tool.

4. Introducing a Simple Unit Test in JUnit

This video discusses a simple unit test that is written using JUnit.

5. Structure of a Unit Test (Arrange-Act-Assert and Given/When/Then)

This video explains the structure of a typical unit test.

6. Conventions for Writing Unit Tests

This video explains the various conventions that you must use while writing a unit test.

7. Characteristics of Proper Unit Tests

This video illustrates the characteristics of a proper unit test.

8. What are Assertions?

This video explains the assertions utility methods in JUnit.

3. Creating a Java Project Using JUnit

1. Section Introduction

This video outlines the concepts that will be covered in this section.

2. Creating a Java Project Using the Maven Quickstart Archetype in JUnit

This video explains how to create a Java project using Maven Quickstart Archetype in JUnit.

3. Introducing a Typical Java Project Structure (Production vs Test Source Trees)

This video discusses the structure of a typical Java project and illustrates the comparison between the production and the test source trees.

4. Understanding the Basic Conventions for Creating Unit Tests (Package and Naming)

This video explains the basic conventions, such as package and naming, that are used for creating unit tests.

4. Writing and Running Unit Tests with JUnit and IntelliJ IDEA

1. Section Introduction

This video outlines the concepts that will be covered in this section.

2. Creating a Test Method with @Test Annotation

This video explains how to create a test method using the JUnit @Test annotation.

3. Running a Unit Test Within the Integrated Development Environment (IDE) and Understanding Test Success

This video explains how to run a unit test inside an IDE and helps you understand the test success.

4. Understanding Test Failures with Exceptions

This video explains how to deal with tests that fail with exception messages.

5. Failing a Unit Test Explicitly with Assert.Fail()

This video explains how to explicitly fail a unit test using the Assert.Fail() method.

6. Using Assert.Fail() to Check Validation Logic in a Try/Catch

This video shows how to use the Assert.Fail() method to check the validation logic in a try/catch unit test.

7. Introduction to the JUnit Assertions API

This video introduces you to the assertions method in JUnit API.

8. Structuring Unit Tests with Arrange-Act Assert

This video shows how to structure unit tests with the Arrange-Act Assert pattern.

9. Understanding the Execution of Assertions and JUnit's Fail-fast Test Failure Mechanism

This video explains how assertions are executed and how JUnit's fail-fast test failure mechanism works.

10. Adding Descriptive Comments to Assertions and Test Failures to Aid Diagnostics

This video explains how to add descriptive comments to assertions and test failures and how to help to diagnose the problems.

11. Coding a Unit Test Following Arrange-Act-Assert

This video shows how to write a unit test using the Arrange-Act-Assert pattern.

12. Keeping Test Setup (Don't Repeat Yourself) DRY with @Before

This video shows how to use the @Before annotation to ensure the unit tests are DRY (Don't Repeat Yourself).

13. Understanding Test Fixture Instantiation

This video explains how to instantiate the test fixtures in JUnit.

5. Using Testing with Mock Objects and Mockito

1. Section Introduction

This video outlines the concepts that will be covered in this section.

2. What Is Mockito and What Are Mock Objects?

This video explains the concept of Mockito and mock objects.

3. Introduction to Testing with Mock Objects

This video provides an introduction to test applications using mock objects.

4. Configuring Projects Using Mockito

This video explains how to configure projects using Mockito.

5. Creating a Project Which Uses JUnit and Mockito

This video explains how to create a project using JUnit and Mockito.

6. Coding a Layered Architecture - Presentation Layer

This video shows how to code the presentation layer of the layered architecture.

7. Coding a Layered Architecture - Business Layer

This video shows how to code the business layer of the layered architecture.

8. Coding a Layered Architecture - Persistence Layer

This video shows how to code the persistence layer of the layered architecture.

9. Putting the Correct Packages in Place to Respect the layering

This video shows how to place the correct packages in a place to ensure that Layering is properly implemented.

10. Writing a Test for the Login Controller in the Presentation Layer

This video shows how to write a test for the login controller in the presentation layer.

11. Understanding the Test Fixture Setup While Writing Mock Object-based Unit Tests

This video explains the test fixture setup that must be used while writing a mock object-based unit test.

12. Writing a Test for the Authentication Service in the Business Layer

This video shows how to write a test for the authentication service in the business layer.

13. Thinking about Design Decisions When Unit Testing

This video explains how to approach the various design decision that you need to make when you test your application.

6. Looking at Hamcrest Assertions Library

1. Section Introduction

This video outlines the concepts that will be covered in this section.

2. Evolving the Domain and Repository Classes

This video discusses the domain and repository classes.

3. Ignoring Tests with @ignore

This video explains how to ignore a test method by using the @ignore annotation.

4. Implementing a Finder in the Repository

This video explains how to implement a finder in the Hamcrest repository.

5. Implementing Business Logic in the Service

This video explains how to implement business logic in the service layer.

6. Configuring Maven to Use Java 8

This video demonstrates how to configure Maven to use Java 8.

7. Evolving the Repository Class

This video explores the various Hamcrest repository class.

8. Adding a Parameter-driven Finder to the Service

This video explains how to add a parameter-driven finder to the service layer.

9. Refactoring to Evolve a New Service

This video explains how to refactor the test codes to evolve a new service.

10. Generating Test Methods in the IDE and Toggling Between Production and Test Code

This video explains how to generate test methods in the IDE and toggle between production and test code.

11. Introducing the JUnit Mockito Runner and @Mock

This video introduces you to JUnit Mockito Runner and the @Mock annotation.

12. Analyzing the Production Code to Determine How to Write the Arrange Section

This video explains how to analyze the production code before writing the arrange section.

13. Using Mockito's @InjectMocks to Create the System Under Test with its Dependencies

This video shows how to use the @InjectMocks annotation to create a system under the test with its dependencies.

14. Keep Yourself Motivated by Checking the Happy Path Test Output

This video shows how to check the output of the happy path test.

15. Using the JUnit Assertions API to Write the Assert Section

This video explains how to use the JUnit assertions API to write the assert section.

16. Thinking about the Weaknesses of the JUnit Assertions API

This video shows how to tackle the weaknesses of the JUnit assertions API.

17. Importance of Checking Your Work as You Go!

This video highlights the importance of checking your work.

18. Upgrading a JUnit Project to Use the Full Hamcrest Version

This video demonstrates how to upgrade a JUnit project to use the full Hamcrest version.

19. Replacing JUnit Assertions with Hamcrest Assertions and Using Assertions with Collections

This video shows how to replace the JUnit assertions with Hamcrest assertions and use assertions with collections

20. Understanding and Reading Hamcrest Test Failures

This video explains what are Hamcrest test failures and how to read them.

21. Quick Thoughts on Hamcrest Individual vs Collection Assertions

This video illustrates the difference between Hamcrest individual and collection assertions.

22. Do Not Invoke Unneeded Production Code in Your Test Classes

This video explains the reason for not invoking unneeded production code in the test classes.

23. Understanding Evaluation of Hamcrest Matchers

This video explains the evaluation of Hamcrest matchers.

24. Thinking about Keeping Production Code to a Minimum in Tests

This video explains why you should keep the production code to a minimum in tests.

25. Creating Complex Hamcrest Assertions with allOf Method and Property Matchers

This video explains how to create complex Hamcrest Assertions with the allOf method and property matchers.

Course Content

  1. JUnit and Mockito Unit Testing for Java Developers

About The Provider

Packt
Packt
Birmingham
Founded in 2004 in Birmingham, UK, Packt’s mission is to help the world put software to work in new ways, through the delivery of effective learning and i...
Read more about Packt

Tags

Reviews