Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Unit Testing in Java Course (How To)

via Treehouse

Overview

Unit testing is a Java best practice that ensures your code is working how it was intended. It is a critical habit that you should develop early on in your coding adventures.

What you'll learn

  • Defining a Unit
  • Composition vs. Inheritance
  • Test fixtures, test suites and the jUnit test runner

Syllabus

Why Test?

Testing is a critical development practice. It provides countless benefits that we will explore.

Chevron 9 steps
  • Introduction

    5:10

  • Defining a Unit

    3:34

  • How we define units

    3 questions

  • Introducing the Project

    4:59

  • Beginning the Project

    3 questions

  • Code Reuse

    6:12

  • Composition vs. Inheritance

    4 questions

  • The Quick Prototype

    6:56

  • Single Responsibility Principle

    2 questions

How to Test

Let's get our testing environment all set up and walk through how to write and then run our tests.

Chevron 8 steps
  • Meet JUnit

    2:56

  • Setting Up a Project for Tests

    10:22

  • Running Tests and Reading Output

    3:55

  • JUnit basics

    3 questions

  • Assertions

    7:44

  • Single Assertions Make For Better Tests

    1 objective

  • Fixtures

    4:44

  • Using Before to not repeat yourself

    1 objective

What to Test

Determining what to test is part of the great art of testing. Let's explore the boundaries and responsibilities of your tests.

Chevron 10 steps
  • The Happy Path and Beyond

    7:40

  • Exceptions

    6:53

  • Happy Path Exception

    1 objective

  • Know Your Bounds

    12:41

  • Rules rule!

    1 objective

  • Ruler of rules

    1 objective

  • What Not To Test

    9:37

  • To Test or Not To Test

    4 questions

  • @AfterClass

    1:46

  • Test the running total

    1 objective

Reviews

Start your review of Unit Testing in Java Course (How To)

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.