Java: Practice Unit Testing
1h 4mIntermediate2023-05-02
Authors

Bethan Palmer
Developer
Course details
The beauty of test-driven development is that it allows you to iterate your codebase one step at a time, testing and reworking individual cases as you go. Not only does this reduce the likelihood of bugs and errors, it also helps you write more effective and more reliable code.
In this course, instructor Bethan Palmer covers the essentials of unit testing in Java to showcase the benefits of test-driven development. Explore practical topics including common assertions, comparing arrays, and testing exceptions as well as some of the more advanced features of JUnit, the Java unit testing framework that lets you run parameterized tests. Along the way, take advantage of the opportunity to practice writing your own unit tests with hands-on, interactive coding exercises in GitHub Codespaces.
In this course, instructor Bethan Palmer covers the essentials of unit testing in Java to showcase the benefits of test-driven development. Explore practical topics including common assertions, comparing arrays, and testing exceptions as well as some of the more advanced features of JUnit, the Java unit testing framework that lets you run parameterized tests. Along the way, take advantage of the opportunity to practice writing your own unit tests with hands-on, interactive coding exercises in GitHub Codespaces.
Skills covered
Software TestingJavaOracleProgramming LanguagesSoftware DevelopmentOne-Off
Concepts
0. Introduction
- 01 - Unit testing in Java
- 02 - What you should know
1. Introduction to Java Unit Testing
- 03 - What is unit testing
- 04 - Test-driven development
- 05 - Follow along with GitHub Codespaces
2. JUnit
- 06 - Setting up JUnit
- 07 - Defining a JUnit test
- 08 - Challenge - JUnit tests
- 09 - Solution - JUnit tests
3. Assertions in JUnit
- 10 - Asserting true and false
- 11 - Comparing arrays
- 12 - Asserting an exception is thrown
- 13 - Challenge - Assertions and annotations
- 14 - Solution - Assertions and annotations
4. Advanced Features
- 15 - Using assumptions
- 16 - Testing multiple inputs with parameterized tests
- 17 - Testing enums with parameterized tests
- 18 - Challenge - Advanced features
- 19 - Solution - Advanced features
Conclusion
- 20 - Next steps