Skip to Content
The Java Workshop
book

The Java Workshop

by David Cuartielles, Pradeep Kumar Gupta, Scott Cosentino, Andreas Göransson, Eric Foster-Johnson, Avinash Kate
October 2019
Beginner
606 pages
10h 37m
English
Packt Publishing
Content preview from The Java Workshop

18. Unit Testing

Overview

This chapter focuses on testing with JUnit, one of the primary testing frameworks for Java. In its earliest sections and exercises, you will learn to write a successful unit test with JUnit to test your code, using assertions to verify that your code is correct. You will then be introduced to parameterized tests—a type of unit test which allows you to run the same test on a set of data inputs—which you will also learn to write. Finally, the chapter will define mocking, which is the technique whereby you will practice how to 'mock out' external dependencies so that you can concentrate on testing a single Java class.

Introduction

Testing allows you to make sure your Java code performs correctly. For example, if ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern Java Collections

Modern Java Collections

Simon Roberts
Java By Comparison

Java By Comparison

Simon Harrer, Linus Dietz, Jörg Lenhard

Publisher Resources

ISBN: 9781838986698Supplemental Content