Book description
JUnit is the gold standard for unit testing Java applications. Filled with powerful new features designed to automate software testing, JUnit 5 boosts your productivity and helps avoid debugging nightmares. Whether you're just starting with JUnit or you want to ramp up on the new features, JUnit in Action, Third Edition has you covered. Extensively revised with new code and new chapters, JUnit in Action, Third Edition is an up-to-date guide to smooth software testing. Dozens of hands-on examples illustrate JUnit 5's innovations for dependency injection, nested testing, parameterized tests, and more. Throughout, you’ll learn how to use JUnit 5 to automate your testing, for a process that consumes less resources, and gives you more time for developing.About the Technology
The JUnit framework is the gold standard for unit testing Java applications—and knowing it is an essential skill for Java developers. The latest version, JUnit 5, is a total overhaul, now supporting modern Java features like Lambdas and Streams.
About the Book
JUnit in Action, Third Edition has been completely rewritten for this release. The book is full of examples that demonstrate JUnit's modern features, including its new architecture; nested, tagged, and dynamic tests; and dependency injection. You'll benefit from author Cătălin Tudose's unique "pyramid" testing strategy, which breaks the testing process into layers and sets you on the path to bug-free code creation.
What's Inside
- Migrating from JUnit 4 to 5
- Effective test automation
- Test-driven development and behavior-driven development
- Using mocks for test isolation
- Connecting JUnit 5 with Maven or Gradle
About the Reader
For intermediate Java developers.
About the Authors
Cătălin Tudose has a Ph.D. in Computer Science, and over 15 years of experience as a Senior Java Developer and Technical Team Lead. Previous editions were authored by Petar Tahchiev, Felipe Leme, Gary Gregory, and Vincent Massol.
Quotes
Every tool you need to gain a solid, comprehensive understanding of JUnit.
- Becky Huett, Big Shovel Labs
A wealth of information about JUnit 5, and about testing!
- Junilu Lacar, Accenture | SolutionsIQ
The ultimate reference book you need to migrate your unit tests to JUnit 5!
- Jean-François, MorinLaval University
Writing good code takes more than just writing unit tests, and this book shows you the way.
- Burk Hufnagel, Daugherty Business Solutions
Table of contents
- JUnit in Action
- Copyright
- dedication
- contents
- front matter
- Part 1. JUnit
- 1 JUnit jump-start
- 2 Exploring core JUnit
- 3 JUnit architecture
- 4 Migrating from JUnit 4 to JUnit 5
- 5 Software testing principles
- Part 2. Different testing strategies
-
6 Test quality
- 6.1 Measuring test coverage
-
6.2 Writing testable code
- 6.2.1 Understanding that public APIs are contracts
- 6.2.2 Reducing dependencies
- 6.2.3 Creating simple constructors
- 6.2.4 Following the Law of Demeter (Principle of Least Knowledge)
- 6.2.5 Avoiding hidden dependencies and global state
- 6.2.6 Favoring generic methods
- 6.2.7 Favoring composition over inheritance
- 6.2.8 Favoring polymorphism over conditionals
- 6.3 Test-driven development
- 6.4 Behavior-driven development
- 6.5 Mutation testing
- 6.6 Testing in the development cycle
- Summary
- 7 Coarse-grained testing with stubs
- 8 Testing with mock objects
- 9 In-container testing
- Part 3. Working with JUnit 5 and other tools
- 10 Running JUnit tests from Maven 3
- 11 Running JUnit tests from Gradle 6
- 12 JUnit 5 IDE support
- 13 Continuous integration with JUnit 5
- Part 4. Working with modern frameworks and JUnit 5
- 14 JUnit 5 extension model
- 15 Presentation-layer testing
- 16 Testing Spring applications
- 17 Testing Spring Boot applications
- 18 Testing a REST API
- 19 Testing database applications
- Part 5. Developing applicationswith JUnit 5
- 20 Test-driven development with JUnit 5
- 21 Behavior-driven development with JUnit 5
- 22 Implementing a test pyramid strategy with JUnit 5
- appendix A. Maven
- appendix B. Gradle
- appendix C. IDEs
- appendix D. Jenkins
- index
Product information
- Title: JUnit in Action, Third Edition
- Author(s):
- Release date: January 2021
- Publisher(s): Manning Publications
- ISBN: 9781617297045
You might also like
book
Java Unit Testing with JUnit 5: Test Driven Development with JUnit 5
Explore the new way of building and maintaining test cases with Java test driven development (TDD) …
video
JUnit and Mockito Unit Testing for Java Developers
Are you looking for a simple, no-nonsense guide to learning how unit testing works? This video …
video
Mockito Tutorial: Learn mocking with 25 Junit Examples
Writing great unit tests distinguishes good programmers from great programmers. In this course, you will learn …
video
Learn Java Unit Testing with JUnit 5 in 20 Steps
JUnit is a unit testing framework for the Java programming language. JUnit has been important in …