Summary

This chapter contains a comprehensive summary of the advance capabilities to write rich Jupiter tests driven by examples. First, we have learned that parameters can be injected in constructor and methods in test classes. JUnit 5 provides three parameter resolvers out of the box, namely resolver for parameters of the type TestInfo (to retrieve information about the current test), resolver for parameters of the type RepetitionInfo (to retrieve information about the current repetition), and resolver for parameters of the type TestReporter (to publish additional data about the current test run).

Another new feature implemented in Jupiter is the concept of dynamic tests. So far in JUnit 3 and 4, tests are defined at compile time (that is static tests). Jupiter introduces the annotation @TestFactory that allows to generate test at runtime. Another new concept provided by the Jupiter programming model are the test templates. These templates re defined using the annotation @TestTemplate and are not regular test cases but rather a template for test cases.

JUnit 5 implements an enhancement support for parameterized tests. In order to implement this type of tests, the annotation @ParameterizedTest must be used. Together with this annotation, an argument provider should be also specified. To that aim, several annotations are provided in Jupiter: @ValueSource, @EnumSource, @MethodSource, @CsvSource, @CsvFileSource, and @ArgumentSource.

In the chapter 5, Integration Of JUnit 5 With External Frameworks, we are going to learn how JUnit 5 interacts with external frameworks. Concretely, we are going to review several JUnit 5 extension, which provides capabilities to use Mockito, Spring, Selenium, Cucumber, or Docker. Moreover, we present a Gradle plugin, which allows to execute tests within an Android project. Finally, we find out how to use several REST libraries (for example, REST Assured or WireMock) to test RESTful services.

..................Content has been hidden....................

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