Next-generation Java testing with JUnit 5
Leveraging Java’s functional features with parameterization, conditional execution, and filtering
Test-driven development (TDD) helps detect potential bugs in code early so that they can be fixed with the least amount of time and effort. TDD arose as part of Agile development, and one of the biggest innovations to come from that community is the Java testing library, JUnit.
JUnit has been remarkably stable over the years and is one of the most widely adopted frameworks in the Java world. The latest version, JUnit 5, takes JUnit to the next level. Full of new features like conditional test execution, parametric testing, labeling and filtering tests, and more, it brings all the modern thinking on testing into the JUnit world. It also takes advantage of the functional features added to Java since version 8 to create a powerful, new library for testing your code. In this hands-on training, Ken Kousen shows you how to adopt JUnit 5's new features and techniques to improve the quality of your code while maintaining backward compatibility.
What you'll learn-and how you can apply it
By the end of this live online course, you’ll understand:
- The unit testing model provided by JUnit
- How the new version uses functional Java SE8 concepts like lambdas, method references, and streams to build better tests
And you’ll be able to:
- Create parameterized tests
- Use the "vintage" library to support backward compatibility
- Handle expected exceptions elegantly
- Use JUnit 5 in your IDE
This training course is for you because...
- You're a Java developer who wants to write unit tests that detect problems as early as possible to ensure your code is correctly doing what it should.
- You're a Java developer or QA engineer who needs to maintain unit tests written by others, adapting them as necessary to changing requirements.
- You're interested in better understanding test-driven development and applying its principles to your code development.
- You're a developer who has used any previous versions of JUnit, and you want to understand the major changes incorporated into the new version.
- A working knowledge of Java
- A basic understanding of unit testing
- Familiarity with earlier versions of JUnit (useful but not required)
Beginning Java, 2nd edition (Learning Path)
- Mockito and the Hamcrest matchers OLC (link coming soon)
About your instructor
Ken Kousen is the author of the books Kotlin Cookbook (O'Reilly), Modern Java Recipes (O'Reilly), Gradle Recipes for Android (O’Reilly) and Making Java Groovy (Manning), as well as O’Reilly video courses in Android, Groovy, Gradle, Advanced Java, and Spring. Ken is a Java Champion. He is a regular speaker on the No Fluff, Just Stuff conference tour and a JavaOne Rock Star, and has spoken at conferences all over the world. Through his company, Kousen I.T., Inc., he has taught software development training courses to thousands of students.
The timeframes are only estimates and may vary according to how the class is progressing
Overview (10 minutes)
- Lecture: What is JUnit 5?; supported Java versions; getting help
Installation (25 minutes)
- Lecture: Dependency metadata; JUnit Jupiter sample projects
- Hands-on exercise: Download and install JUnit 5 using a build tool
Break (10 minutes)
Writing tests (60 minutes)
- Lecture and hands-on exercises: Annotations; the standard test class; display names; assertions; disabling tests; conditional test execution; nested tests; repeated tests; parameterized tests; test templates; dynamic tests
Break (10 minutes)
Running tests (15 minutes)
- Lecture: IDE support; build support; using JUnit 4 to run the JUnit Platform; configuration parameters
Extension model (25 minutes)
- Lecture: Registering extensions; conditional test execution; parameter resolution; exception handling
- Hands-on exercise: Test for exceptions and more
Migrating from JUnit 4 (15 minutes)
- Lecture: Running JUnit 4 Tests on the JUnit Platform; migration tips
Wrap-up and Q&A (10 minutes)