Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Software Testing with JUnit 5

You're reading from   Mastering Software Testing with JUnit 5 Comprehensive guide to develop high quality Java applications

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781787285736
Length 350 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Boni Garcia Boni Garcia
Author Profile Icon Boni Garcia
Boni Garcia
Arrow right icon
View More author details
Toc

Test interfaces

In JUnit 5, there are different rules relative to the use of annotations in Java interfaces. First of all, we need to be aware that @Test, @TestFactory, @BeforeEach, and @AfterEach can be declared on interface default methods.

Default methods is a feature of Java introduced in version 8. These methods (declared using the reserve keyword default) allows to define a default implementation for a given method within a Java interface. This capability can be useful for backward compatibility with existing interfaces.

The second rule regarding JUnit 5 and interfaces is that @BeforeAll and @AfterAll can be declared on static methods in a test interface. Moreover, if the test class, which implements a given interface, is annotated with @TestInstance(Lifecycle.PER_CLASS), the methods @BeforeAll and @AfterAll declared on the interface do not need to be static, but default...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime