Skip to product information
JUnit IN ACTION 3rd Edition
JUnit IN ACTION 3rd Edition
Description
Book Introduction
Everything You Need to Know About Java Unit Testing

JUnit is the de facto standard for unit testing Java applications.
JUnit has become a must-have for Java developers.
In particular, JUnit 5 has significantly improved its functionality to match modern Java (Java 8 version) and supports the latest Java features such as lambda expressions and streams.
『JUnit in Action 3rd Edition』 has been rewritten for JUnit 5.
This book covers the latest techniques and new architectures of JUnit, including nested testing, testing with tags, dynamic testing, and dependency injection.
Java champion and author Katharine Tudose offers a unique test pyramid strategy.
By utilizing the testing strategies covered in this book, you can divide the testing process into several stages and write source code with minimal bugs.
  • You can preview some of the book's contents.
    Preview

index
Part 1 JUnit

Chapter 1: Getting Started with JUnit


1.1 Proving that the program works properly
1.2 Starting from scratch
-1.2.1 Understanding the Unit Testing Framework
-1.2.2 Adding unit tests
1.3 Installing JUnit
1.4 Testing with JUnit
organize

Chapter 2: JUnit Core Overview

2.1 Core Annotations
-2.1.1 @DisplayName
-2.1.2 @Disabled
2.2 Overlap Test
2.3 Testing with tags
2.4 Assertion
2.5 Family statement
2.6 Dependency Injection in JUnit 5
-2.6.1 TestInfoParameterResolver
-2.6.2 TestReporterParameterResolver
-2.6.3 RepetitionInfoParameterResolver
2.7 Repeated Testing
2.8 Testing with parameters
2.9 Dynamic Testing
2.10 Using Hamcrest Matchers
organize

Chapter 3 JUnit Architecture

3.1 The Concept and Importance of Software Architecture
-3.1.1 First Story: The Phone Book
-3.1.2 Second Story: The Sneaker Manufacturer
3.2 JUnit 4 Architecture
-3.2.1 JUnit 4 Monolithic Architecture
-3.2.2 JUnit 4 runner
-3.2.3 JUnit 4 rule
-3.2.4 Drawbacks of JUnit 4 Architecture
3.3 JUnit 5 Architecture
-3.3.1 JUnit 5 Modularity
-3.3.2 JUnit Platform
-3.3.3 JUnit Jupiter
-3.3.4 JUnit Vintage
-3.3.5 JUnit 5 Internal Architecture Diagram
organize

Chapter 4: Migrating from JUnit 4 to JUnit 5

4.1 Transition process from JUnit 4 to JUnit 5
4.2 Dependencies required to migrate from JUnit 4 to JUnit 5
4.3 JUnit 5 Annotations, Classes, and Methods
-4.3.1 Annotations, classes, and methods used similarly in JUnit 4 and JUnit 5
-4.3.2 @Category in JUnit 4 and @Tag in JUnit 5
-4.3.3 Switching Hamcrest Matcher Functionality
-4.3.4 JUnit 4 rule and JUnit 5 extension model
-4.3.5 Converting a custom rule to an extension
organize

Chapter 5 Software Testing Principles

5.1 Why Unit Test?
-5.1.1 Can increase test coverage
-5.1.2 Improved team productivity
-5.1.3 Reduce debugging effort by detecting regressions in advance.
-5.1.4 You can refactor with confidence
- Helps implement features in 5.1.5
-5.1.6 Document the expected behavior of your code.
-5.1.7 Allows you to measure code coverage and various metrics.
5.2 Test Types
-5.2.1 Unit Tests
-5.2.2 Integration Testing
-5.2.3 System Testing
-5.2.4 Acceptance Test
5.3 Black-box testing vs. white-box testing
-5.3.1 Black Box Test
-5.3.2 White Box Testing
-5.3.3 Comparison of Pros and Cons
organize

Part 2: Various Testing Strategies

Chapter 6 Testing Quality


6.1 Measuring Test Coverage
-6.1.1 What is Test Coverage?
-6.1.2 Tools for measuring code coverage
6.2 Writing easy-to-test code
-6.2.1 A public API is a contract between information providers and information users.
-6.2.2 Reducing Dependencies
-6.2.3 Creating a Simple Constructor
-6.2.4 Following the Law of Demeter
-6.2.5 Avoiding Hidden Dependencies and Global State
-6.2.6 Using generic methods
-6.2.7 Use composition rather than inheritance
-6.2.8 Use polymorphism rather than branching statements
6.3 TDD
-6.3.1 Adapting to the Development Cycle
-6.3.2 Performing TDD Step 2
6.4 Behavior-Driven Development
6.5 Performing mutation testing
6.6 Testing within the development cycle
organize

Chapter 7: Rough Testing Using Stubs

7.1 Examining the stub
7.2 Testing HTTP Connections with Stubs
-7.2.1 What to replace with stubs
-7.2.2 Using Jetty as an Embedded Web Server
7.3 Creating a Web Server Resource with a Stub
-7.3.1 Setting up the first stub
-7.3.2 Revisiting the First Stub Test
7.4 Creating an HTTP Connection with a Stub
-7.4.1 Creating a Custom URL Protocol Handler
-7.4.2 Creating an HttpURLConnection stub
-7.4.3 Performing tests that replace HTTP connections with stubs
organize

Chapter 8: Testing with Mock Objects

8.1 What is a mock object?
8.2 Unit Testing Using Mock Objects
8.3 Refactoring using mock objects
-8.3.1 Refactoring Example
-8.3.2 Considerations for Refactoring
8.4 Simulating HTTP Connections
-8.4.1 Defining a Mock Object
-8.4.2 Testing the Example Method
-8.4.3 First Attempt: Easy Refactoring Techniques
-8.4.4 Second Attempt: Refactoring Using Class Factories
8.5 Using Mock Objects as Trojan Horses
8.6 Using the Mock Object Framework
-8.6.1 EasyMock
-8.6.2 JMock
-8.6.3 Mockito
organize

Chapter 9: Testing with Containers

9.1 Limitations of General Unit Testing
9.2 Testing with Mock Objects
9.3 Using Containers
-9.3.1 Test Implementation Strategy Using Containers
-9.3.2 Testing Framework Using Containers
9.4 Comparing stub, mock, and container testing
-9.4.1 Stub Evaluation
-9.4.2 Mock Object Evaluation
-9.4.3 Test Evaluation Using Containers
9.5 Testing with Arquillian
organize

Part 3: Using JUnit 5 with Various Tools

Chapter 10: Running JUnit Tests with Maven 3


10.1 Creating a Maven Project
10.2 Using Maven Plugins
-10.2.1 Maven Complier Plugin
-10.2.2 Maven Surefire Plugin
-10.2.3 Creating JUnit Reports with Maven
10.3 All at once
10.4 Maven Tasks
organize

Chapter 11: Running JUnit Tests with Gradle 6

11.1 Gradle Overview
11.2 Setting up a Gradle project
11.3 Using the Gradle Plugin
11.4 Creating a Gradle Project and Testing It with JUnit 5
11.5 Comparing Gradle and Maven
organize

Chapter 12 JUnit 5 and Multiple IDE Support

12.1 Using JUnit 5 with IntelliJ IDEA
12.2 Using JUnit 5 with Eclipse
12.3 Using JUnit 5 with NetBeans
12.4 Comparing JUnit 5 Usage in Three IDEs
organize

Chapter 13: JUnit 5 and Continuous Integration

13.1 Testing and Continuous Integration
13.2 Exploring Jenkins
13.3 Practicing Continuous Integration
13.4 Configuring Jenkins
13.5 Working in a Continuous Integration Environment
organize

Part 4: Using JUnit in Modern Frameworks

Chapter 14 JUnit 5 Extension Model


14.1 Exploring the JUnit 5 Extension Model
14.2 Creating a JUnit 5 extension
14.3 Implementing JUnit 5 Tests Using Extension Points
-14.3.1 Persisting passenger information to the database
-14.3.2 Verifying Passenger Uniqueness
organize

Chapter 15: Testing the Presentation Layer

15.1 Choosing a Testing Framework
15.2 A Look at HtmlUnit
-15.2.1 HtmlUnit Practical Examples
15.3 Writing HtmlUnit Tests
-15.3.1 HTML assertions
-15.3.2 Testing Specific Web Browsers
-15.3.3 Testing Multiple Browsers
-15.3.4 Creating a Standalone GUI Test
-15.3.5 Testing HTML Forms
-15.3.6 Testing JavaScript
15.4 A Look at Selenium
15.5 Writing Tests with Selenium
-15.5.1 Testing Specific Web Browsers
-15.5.2 Testing Navigation Using a Web Browser
-15.3.3 Testing with Multiple Browsers
-15.5.4 Testing Google Search and Navigation in Multiple Browsers
-15.5.5 Testing Website Authentication
15.6 HtmlUnit and Selenium
organize

Chapter 16: Testing Spring Applications

16.1 Exploring the Spring Framework
16.2 Examining Dependency Injection
16.3 Using and Testing Spring Applications
-16.3.1 Creating a Spring Context Programmatically
-16.3.2 Using the Test Context Framework in Spring
16.4 Using SpringExtension with JUnit 5 Jupiter
16.5 Adding new features and testing them with JUnit 5
organize

Chapter 17: Testing Spring Boot Applications

17.1 Spring Boot Overview
17.2 Creating a Project with Spring Initializer
17.3 Migrating a Spring Application to Spring Boot
17.4 Implementing a Test-Only Configuration in Spring Boot
17.5 Adding and Testing New Features to a Spring Boot Application
organize

Chapter 18: Testing REST APIs

18.1 Examining REST Applications
18.2 Creating a RESTful API to Manage a Single Entity
18.3 Creating a RESTful API that Manages Multiple Entities
18.4 Testing RESTful APIs
organize

Chapter 19: Testing Database Applications

19.1 Impedance mismatch during database unit testing
-19.1.1 Unit tests should be run in isolation from the code.
-19.1.2 Unit tests should be easy to write and run.
-19.1.3 Unit tests should run fast.
19.2 Testing JDBC Applications
19.3 Testing Spring JDBC Applications
19.4 Testing Hibernate Applications
19.5 Testing Spring Hibernate Applications
19.6 Comparing Database Application Tests
organize

Part 5: Development Methodology Using JUnit 5

Chapter 20: TDD with JUnit 5


20.1 Core Concepts of TDD
20.2 Flight Management System
20.3 Preliminary Preparation for Developing a Flight Management System with TDD
20.4 Refactoring the Flight Management System
20.5 Adding New Features with TDD
-20.5.1 Adding Premium Flights
-20.5.2 Add feature to prevent duplicate passenger additions
organize

Chapter 21: BDD with JUnit 5

21.1 Examining BDD
-21.1.1 Adding new features
-21.1.2 From requirements analysis to acceptance criteria
-21.1.3 Benefits and Challenges of BDD
21.2 Practicing BDD with Cucumber and JUnit 5
-21.2.1 Cucumber Overview
-21.2.2 Moving features created with TDD to Cucumber
-21.2.3 Adding new features using Cucumber
21.3 Practicing BDD with JBehave and JUnit 5
-21.3.1 JBehave Overview
-21.3.2 Moving features created with TDD to JBehave
-21.3.3 Adding new features using JBehave
21.4 Comparing Cucumber and JBehave
organize

Chapter 22: Implementing a Test Pyramid Strategy with JUnit 5

22.1 Software Testing Levels
22.2 Unit Testing: Basic Components That Work Independently
22.3 Integration Testing: Collaboration Between Units
22.4 System Testing: A Look at the Complete Software
-22.4.1 Testing with mock external dependencies
-22.4.2 Testing with Partially Implemented External Dependencies
-22.4.3 Testing with fully implemented external dependencies
22.5 Acceptance Testing: Complying with Business Requirements
organize

Appendix A Maven

A.1 Custom over setting
A.2 Strong Dependency Management
A.3 Maven Build Life Cycle
A.4 Plug-in-based architecture
A.5 Maven Project Object Model
A.6 Installing Maven

Appendix B Gradle

B.1 Installing Gradle
B.2 Creating a Task with Gradle

Appendix C IDE

C.1 Installing IntelliJ IDEA
C.2 Installing Eclipse
C.3 Installing NetBeans

Appendix D Jenkins

Publisher's Review
What this book covers

ㆍ Migrating from JUnit 4 to JUnit 5
ㆍ Efficiently automating tests
ㆍ TDD and BDD
Using mock objects for test isolation
ㆍ Handling JUnit 5 with Maven or Gradle
GOODS SPECIFICS
- Date of issue: May 28, 2024
- Page count, weight, size: 664 pages | 1,246g | 188*240*32mm
- ISBN13: 9788966264407
- ISBN10: 8966264409

You may also like

카테고리