JUnit 5 Standard Tests

Talk is cheap. Show me the code.
- Linus Torvalds

JUnit 5 provides a brand-new programming model called Jupiter. We can see this programming model as an API for software engineers and testers which allow to create JUnit 5 tests. These tests are later executed on the JUnit Platform. As we will discover, the Jupiter programming model allows to create many different types of tests. This chapter tackles the basics of Jupiter. To that aim, this chapter is structured as follows:

  • Test lifecycle: In this section, we analyze the structure of the Jupiter tests, describing the annotations involved in the management of the test life cycle in the JUnit 5 programming model. Then, we discover how to skip tests, and also how to annotate tests with a custom display name.
  • Assertions: In this section, first we present a brief overview of the verification assets, called assertions (also known as predicates). Second, we study how the assertions have been implemented in Jupiter. Finally, we present several third-party libraries about assertions, providing some examples for Hamcrest.
  • Tagging and filtering tests: In this section, first we will learn how to label Jupiter tests, that is, how to create tags in JUnit 5. Then, we will learn how to filter our tests using Maven and Gradle. Finally, we are going to analyze how to create meta-annotations using Jupiter.
  • Conditional test execution: In this section, we will learn how to disable tests based on a given condition. After that, we make a review of the so-called assumptions in Jupiter, which are a mechanism provided out of the box by Jupiter to run tests only if certain conditions are as expected.
  • Nested tests: This section presents how Jupiter allows to express the relationship among a group of tests, called nested tests.
  • Repeated tests: This section reviews how Jupiter provides the ability to repeat a test a specified number of times.
  • Migration from JUnit 4 to JUnit 5: This section provides a set of hints about the main differences between JUnit 5 and its immediate antecessor, that is, JUnit 4. Then, this section presents the support for several JUnit 4 rules within Jupiter tests.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.204.186