in September 2017 2 Source: http://blog.takipi.com/the-top-100-java-libraries-in-2017-based-on-259885-source-files/ JUnit Framework EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM The top 20 Java libraries on GitHub in 2017
+ Vintage 5th planet in Solar System! Source: http://junit.org/junit5/docs/current/user-guide/#dependency-diagram EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
IDEs and build tools to launch the framework. Finds test engines via Java’s ServiceLoader mechanism. ▪ junit-platform-engine TestEngine APIs for integration of any testing framework that runs on platform. JUnit Jupiter ▪ junit-jupiter-api APIs for the new programming and extension model. ▪ junit-jupiter-engine JupiterTestEngine - To discover and execute Jupiter tests. JUnit Vintage ▪ junit-vintage-engine To discover and execute JUnit 3 and JUnit 4 tests on JUnit 5 platform. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM JUnit 5 Architecture
Jupiter test in Eclipse with lifecycle method stubs for a class and its methods under test: 9 New JUnit Test Case wizard -> New JUnit Jupiter test EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
JUnit Test Case wizard offers to add it while creating a new JUnit Jupiter test. Quick Fix (Ctrl+1) proposal on @Test. Add library (JUnit) in Java Build Path dialog. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
end of arguments list. • Failure message can be retrieved lazily. • Grouped assertions to execute all assertions first and then report all failures together. • Exception testing to assert and evaluate a thrown exception. • Asserting that the given task completes before the given timeout. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
added to Eclipse Favorites by default. 15 Preferences -> Java -> Editor -> Content Assist -> Favorites Import static methods in your code from favorite classes via Content Assist (Ctrl + Space) and Quick Fix (Ctrl + 1). Configure the number of static member imports needed before type.* is used. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM Eclipse Favorites
test methods - with spaces, special characters, and even emojis! Use Go to File action or just double-click to navigate to the test from JUnit view. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
can serve as @Nested tests for logical grouping of test cases. (Re-)Run a single @Nested test class by using the Run action in JUnit view or Outline view. You can even right-click on a nested test class name in the editor and use the Run As action. Example: TestingAStackDemo in JUnit 5 user guide. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
can be inherited by implementing test classes. • Enables multiple inheritance in tests classes. Example: StringTests in JUnit 5 user guide. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
methods with @Tag. • Tags can later be used to filter test execution. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM Provide tags to be included in or excluded from a test run via Configure Tags dialog in its JUnit launch configuration.
be used as meta-annotations. • Create custom composed annotation inheriting semantics of its meta-annotations. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
by a @TestFactory method. Create a @TestFactory method in Eclipse with the new template: • Dynamic container is composed of a display name and a list of dynamic nodes. • Dynamic test is composed of a display name and an Executable. test_factory EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM There are no lifecycle callbacks for individual dynamic tests.
JUnit view’s failure trace to jump to the corresponding source location. Click "Show Stack Trace in Console View" button and use the hyperlinks. It can also be used to copy parts of the stack trace. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
permitted to have parameters enabling Dependency Injection. • ParameterResolver is the extension API to provide a parameter resolver which dynamically resolves a parameter at runtime. • A parameter resolver can be registered via @ExtendWith(…) annotation. • JUnit Jupiter provides some built-in resolvers which are registered automatically: o TestInfo (resolved by TestInfoParameterResolver) to access information about the currently executing test: EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
additional data from the currently executing test which can be seen in the Console view in Eclipse: • To support overloaded test methods, the Test Method Selection dialog in JUnit launch configuration now shows the method parameter types also: EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
with @RepeatedTest and specifying the number of repetitions. • name attribute: to optionally specify a custom display name for each repetition. • RepetitionInfo: as test method parameter to get information about the current repetition. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
arguments by: • annotating the method with @ParameterizedTest • and declaring at least one source to provide the arguments. • name attribute: to optionally specify a custom display name for each invocation. • Test method may have additional parameters to be resolved by other ParameterResolvers at the end of the method's parameter list. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
a new instance of the test class before executing each test method. • To execute all test methods on the same instance of the test class, you can annotate the test class with @TestInstance(Lifecycle.PER_CLASS). • The per-class mode makes it possible to use @BeforeAll and @AfterAll annotations on: o Non-static methods o Interface default methods o Methods in @Nested test classes EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM
Guide for more details. 28 Provides extension points as interfaces in org.junit.jupiter.api.extension package to be implemented by extension providers. Register one or more extensions declaratively on a test class, test method, or composed annotation with @ExtendWith(…). JUnit Jupiter also supports global extension registration via Java’s ServiceLoader mechanism. EclipseCon Europe 2017 | Embracing JUnit 5 with Eclipse | Noopur Gupta, IBM