A Deep Dive into Junit 5

WHEN

-

WHAT

99 Minute Workshop

WHERE

Online

COST

All our 99-minute workshops are included with a Pro membership.

Join Boni for this comprehensive deep dive into the capabilities and power of Junit 5

Topics Boni will cover

We'll explore the following topics

Read full session description ->
  • Tagging and filtering: Label and execute a group of tests
  • Timeout: Specify a configurable time for a test to fail
  • Test order: Specify a given execution order for tests
  • Parameterized tests: Implement data-driven tests
  • Parallel execution: Use a thread-pool to execute a test suite in parallel
  • Lifecycle callbacks and test instance postprocessing: to enhance the default test lifecycle with custom logic
  • Conditional test execution: to custom enable/disable tests
  • Parameter resolution: to implement dependency injection in tests
  • Exception handling: for custom exception manipulation

Meet Your Instructor

Boni García

Boni García

VISITING PROFESSOR

I am Visiting Professor at Universidad Carlos III de Madrid (UC3M) in Spain. My research interests include software engineering and automated testing. I am the author of more than 35 research papers in different journals, magazines, and international conferences. In 2017 I wrote the book "Mastering Software Testing with JUnit 5". I am the creator and maintainer of several open-source projects, such as WebDriverManager (a helper library for Selenium WebDriver) or Selenium-Jupiter (a JUnit 5 extension for Selenium WebDriver).

-

A Deep Dive into JUnit 5

Boni
99 Minute Workshop
Boni García

Version 5 of the popular testing framework JUnit was first released in September 2017. Since then, JUnit 5 is in constant evolution and maintenance. It has been designed using a modular architecture made up of three main components:

  • Platform: Foundation component providing generic capabilities to discover and execute test cases in a Java Virtual Machine (JVM).
  • Vintage: Engine for legacy tests (JUnit 3 and 4).
  • Jupiter: Engine for the new programming and extension model.

Jupiter tests can be executed using a build tool such as Maven, Gradle, or Ant. Besides, modern Integrated Development Environments (IDEs) such as IntelliJ IDEA, Eclipse, or Visual Studio, are shipped with built-in capabilities to execute JUnit tests out of the box.

Java annotations are one of the main building blocks of the Jupiter programming and extension model. For instance, we can specify the logic to exercise and verify a System Under Test (SUT), i.e., a test case (or simply test), using the annotation @Test at method-level in a Java class. Other basic annotations to define the rest of the basic test lifecycle are @BeforeEach/@BeforeAll (setup logic, executed before the test) and (@AfterEach/@AfterAll (teardown logic, executed after the test). When coming to data verification, Jupiter provides a rich API for assertions (e.g., assertTrue, assertFalse, assertEquals, assertArrayEquals, among many others). Besides, we can use a third-party advanced assertions library in conjunction with Jupiter, for example, Hamcrest, Truth, or AssertJ, to name a few.

Jupiter provides a wide variety of additional features to develop different types of tests. In this workshop, we review some of the most relevant.

Finally, we introduce the extension model of Jupiter. An extension in Jupiter is a Java class that allows developers to incorporate extra features to Jupiter. The building block of the Jupiter extension model is the so-called extension points., such as:

Takeaways

  • Tagging and filtering: Label and execute a group of tests
  • Timeout: Specify a configurable time for a test to fail
  • Test order: Specify a given execution order for tests
  • Parameterized tests: Implement data-driven tests
  • Parallel execution: Use a thread-pool to execute a test suite in parallel
  • Lifecycle callbacks and test instance postprocessing: to enhance the default test lifecycle with custom logic
  • Conditional test execution: to custom enable/disable tests
  • Parameter resolution: to implement dependency injection in tests
  • Exception handling: for custom exception manipulation

Prerequisites

Knowledge requirements:

  • Basic knowledge of Java language.

Software requirements:

  • Java 8+ (JDK preferred).
  • Some modern IDE such as Eclipse, IntellijIDEA, Visual Studio, or NetBeans.
  • To clone/fork the code examples GitHub repo: https://github.com/bonigarcia/mastering-junit5
  • A build tool such as Maven or Gradle (optional).

99 Minute Workshops

Short Digestable Live Online Workshops

Live and Instructor-led

All our 99-Minute Workshops are hosted live and led by an instructor.

Short and Targeted

These workshops are a max of two hours long which means they can easy be fit into your busy week. The short time also means they are targeted on a few learning outcomes.

Learn with Others

Connect and learn with other community members during these live online testing workshops.

Available with Pro Membership

All our 99-Minute Workshops are available with Pro Membership, you can attend as many as you like. We also do the odd free workshop with our partners.

All our 99-minute workshops are included with a Pro membership.

Frequently Asked Questions

Are the Workshops Recorded?

Our 99-minute workshpos are designed to be attended live. If you can’t make the scheduled time, it will stay available to replay in CrowdCast for 7 days. To get the most out of them, we highly recommend you attend them live.