Test Driven Development

Try for free!

Subscribe and stream all our courses
from just USD19.00 per month
Start my free trial

Test Driven Development

Junit 4 Junit 5 Java (all)

with JUnit and Mockito

4 hours

  • This course covers the fundamentals of test driven development... not just the theory, but how to use it in real world project examples. This includes mocking with Mockito.
  • The course is valid for all current Java versions (7 and up) and covers JUnit 4 and JUnit 5.
  • The code files for this course are split into 2 sections. Users of Java versions 9 and above should use the JUnit 5 version of the code. Users of Java 8 and below should use the JUnit 4 version.
This course requires basic Java knowledge only. No prior knowledge of JUnit is needed.

Contents

Having problems? check the errata

Introduction

Introducing TDD 3m 6s Preview
What will we test 2m 36s Watch

JUnit

Introducing our first example project 2m 2s Watch
Using the IntelliJ IDE 8m 10s Watch
Creating a project structure for test cases 5m 0s Watch
JUnit Basics 8m 31s Watch

First tests

Thinking about examples and outcomes 2m 57s Watch
Step 1 - getting to red 6m 8s Watch
Step 2 - getting to green 2m 29s Watch
Why you must always start with a failing test! 4m 39s Watch
Adding more tests 5m 52s Watch
Finally writing some code 7m 39s Watch

Practising the basics

Testing for exceptions - and challenge number 1 9m 41s Watch
Challenge 2 - writing a test 2m 38s Watch
Solution to challenge 2 3m 36s Watch
Getting to more complex requirements and finding hidden bugs 11m 48s Watch
Challenge 3 - Adding further business requirements 11m 33s Watch

Refactoring

Getting started with refactoring - extracting constants 5m 43s Watch
More refactoring - restructuring our code 4m 32s Watch

Best practice

What is a good or bad test? 6m 58s Watch
JUnit Asserts 5m 24s Watch

Stubs

The challenge of testing code that has dependencies 3m 55s Watch
Creating a test stub using just Java 14m 10s Watch

Mocks

Why we want to test behaviour as well as logic 5m 58s Watch
Setting up Mockito and creating a mock 8m 44s Watch
Using mocks to test behaviour 9m 22s Watch
Mockito syntax options 2m 36s Watch

Dummies, Fakes and avoiding Tautologies

What are Fakes or Dummies 5m 5s Watch
Practical exercise - using Mockito to create a stub 4m 30s Watch
Refactoring our tests - using setup and teardown 7m 32s Watch
How to avoid tautologies 9m 17s Watch

Putting it into practice & spying - handling legacy code

Loading up the case study 4m 27s Watch
Understanding the challenge part 1 8m 21s Watch
Understanding the challenge part 2 8m 34s Watch
Using a Spy 13m 1s Watch
Practical exercise - finding the fault in the business logic 14m 22s Watch
Copyright ©2024 VirtualPairProgrammers.com