O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learn Java Unit Testing with JUnit 5 in 20 Steps

Video Description

JUnit tutorial for beginners with examples

About This Video

  • Create a new project for JUnit tests
  • Create and run JUnit tests
  • Write good unit tests
  • Use assert methods
  • Use basic JUnit annotations
  • @Test, @BeforeEach, @AfterEach, @AfterAll, @BeforeAll
  • Test performance and exceptions in unit tests
  • Write parameterized tests- adhere to JUnit best practices
  • Use Eclipse to write and run JUnit tests

In Detail

JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development and is one of a family of unit testing frameworks which is collectively known as xUnit frameworks. In this beginners tutorial on JUnit, you will learn how to

Table of Contents

  1. Chapter 1 : JUnit 5
    1. Introduction 00:02:08
    2. Course Overview 00:02:00
    3. Step 01 - Introduction to Unit Testing - Test Pyramid 00:04:47
    4. Step 02 - First Junit Test - Red bar 00:04:21
    5. Step 03 - Absence of failure is success 00:04:54
    6. Step 04 - First Unit Test with JUnit - String length() method 00:04:31
    7. Step 05 - Writing JUnit Assertions - assertNull and assertTrue 00:06:33
    8. Step 06 - Writing Assertions for Arrays - assertArrayEquals 00:06:57
    9. Step 07 - Setting up data for every test - @BeforeEach, @AfterEach 00:05:22
    10. Step 08 - Setting up database connections - @BeforeAll, @AfterAll 00:03:32
    11. Step 09 - Tip - Testing Exceptions with Junit 00:06:38
    12. Step 10 - Tip - @DisplayName and test methods need not be public 00:01:56
    13. Step 11 - Basics of Parameterized tests 00:04:29
    14. Step 12 - Advanced Paramaterized Tests with Csv Source 00:06:27
    15. Step 13 - Tip - Giving a name to a Parameterized Test 00:02:13
    16. Step 14 - Tip - Repeat same test multiple times 00:01:43
    17. Step 15 - Tip - Unit Testing for Performance 00:05:04
    18. Step 16 - Tip - Disable Unit Tests 00:02:32
    19. Step 17 - Tip - Grouping Tests with @Nested 00:06:15
    20. Step 18 - Tip - JUnit 5 = Platform + Jupiter + Vintage 00:02:51
    21. Step 19 - Tip - JUnit 4 vs JUnit 5 00:03:04
    22. Step 20 - Tip - JUnit Best Practices 00:05:34
    23. Step 21 - Tip - JUnit Patterns - xunitpatterns 00:01:22
  2. Chapter 2 : JUnit 4
    1. Step 99 - JUnit 4 Section - First Version of the course 00:00:43
    2. Getting Ready for Hello World 00:08:05
    3. Your First JUnit Success - Green Bar 00:09:39
    4. Refactoring: Improving the Junit 00:07:44
    5. assertTrue and assertFalse 00:14:45
    6. @Before and @After 00:07:02
    7. @BeforeClass and @AfterClass 00:03:30
    8. Comparing Arrays - assertArrayEquals 00:05:19
    9. Unit Testing Exceptions 00:03:33
    10. Unit Testing for Performance 00:04:03
    11. Parameterized JUnit Tests 00:11:11
    12. Organizing Unit Tests into Suites 00:03:24
    13. How do you write good Unit Tests? 00:10:11
    14. Conclusion 00:00:58