watching now
3 Students
65 Lessons
Intermediate

What Will You Learn?

  • Be able to write unit tests confidently using JUnit
  • Appreciate mocking and mock objects and understand how to test interactions with Mockito
  • Be able to use Mockito to create test fixtures, stub methods by programmatic and annotation-driven test setup
  • Understand how to analyse production code to guide writing unit tests
  • Understand modern unit testing concepts and best practices

Curriculum

2h 56m
Section 2: Unit Testing Foundations
31:48
Introducing a Simple Unit Test in JUnit
03:02
Structure of a Unit Test (Arrange-Act-Assert and Given/When/Then)
05:09
Conventions for Writing Unit Tests
02:42
Characteristics of Proper Unit Tests
05:49
What are Assertions?
07:51
Section 3: Creating a Java Project which uses JUnit
09:57
Section introduction
00:36
Creating a Java project which includes JUnit using the Maven Quickstart Archetype
02:52
Introducing a typical Java project structure (production vs test source trees)
02:47
Understanding the basic conventions for creating unit tests (package and naming
03:42
Section 4: Writing and Running Unit Tests with JUnit and IntelliJ IDEA
26:04
Section introduction
00:53
Creating a test method with the @Test annotation
01:39
Running a unit test within the IDE and understanding test success
01:21
Understanding test failures with exceptions
02:21
Failing a unit tests explicitly with Assert.fail
00:46
Using Assert.fail to check validation logic in a try/catch
02:23
An introduction to the JUnit Assertions API
01:54
Structuring unit tests with Arrange/Act/Assert
02:05
Understanding execution of assertions and JUnit's fail-fast test failure mechani
03:29
Adding descriptive comments to assertions and test failures to aid diagnostics
00:49
Coding a unit test following Arrange-Act-Assert
01:13
Keeping test setup DRY with @Before
04:56
Understanding test fixture instantiation
02:15
Section 5: Unit Testing with Mock Objects and Mockito
46:20
Section introduction
01:12
What is Mockito and what are mock objects?
03:58
Introduction to testing with mock objects
04:56
Configuring Projects to Use Mockito
02:46
Creating a project which uses JUnit and Mockito
04:07
Coding a Layered Architecture - Presentation Layer
03:27
Coding a Layered Architecture - Business Layer
03:32
Coding a Layered Architecture - Persistence Layer
04:12
Putting the correct packages in place to respect the layering
02:45
Writing a test for the Login Controller in the presentation layer
09:48
Understanding the test fixture setup when writing mock object based unit tests
01:02
Writing a test for the Authentication Service in the business layer
03:57
Thinking about design decisions when unit testing
00:38
Section 6: Looking at the Hamcrest Assertions Library
59:46
Section Introduction
00:58
Evolving the Domain and Repository Classes
06:37
Ignoring Tests with @ignore
04:18
Implementing a Finder in the Repository
00:58
Implementing Business Logic in the Service
03:13
Configuring Maven to use Java 8
02:32
Evolving the Repository Class
01:32
Adding a Parameter-driven Finder to the Service
01:34
Refactoring to Evolve a New Service
01:16
Generating Test Methods in the IDE and Toggling Between Production and Test Code
01:27
Introducing the JUnit Mockito Runner and @Mock
01:05
Analyzing the Production Code to Determine How to Write the Arrange Section
03:58
Using Mockito's @InjectMocks to Create the System Under Test with it's Dependenc
01:33
Keep Yourself Motivated by Checking the Happy Path Test Output
02:06
Using the JUnit Assertions API to write the Assert Section
05:18
Thinking About the Weaknesses of the JUnit Assertions API
02:00
The Importance of Checking Your Work as you Go!
02:29
Upgrading a JUnit project to use the full Hamcrest version
03:12
Replacing JUnit assertions with Hamcrest assertions and using assertions with co
02:13
Understanding and Reading Hamcrest Test Failures
02:46
Quick thoughts on Hamcrest individual vs collection Assertions
00:30
Don't invoke unneeded production code in your test classes
01:02
Understanding Evaluation of Hamcrest Matchers
01:18
Thinking about why we keep production code to a minimum in tests
01:19
Creating Complex Hamcrest Assertions with allOf and Property Matchers
04:32

Description

Requirements

  • Have some knowledge of coding in Java to at least a basic level
  • An awareness and excitement to learn all about unit testing with Junit, Mockito and Hamcrest!
  • Have an interest in understanding unit testing from the ground up through theory and practical examples

About the Instructor

Reviews 0
Students 4
Courses 3

Matt Speake is a professional software engineer specializing in Java technologies. He has over 20 years experience working everywhere from small startups to large global corporations and is the principal trainer at Zention in the UK.

You can find him writing and recording about all things Java at the Java Easily website.

BitDegree platform reviews

Our students say Excellent
4.5 out of 5
trustpilot logo 1 trustpilot logo