JUnit 4 & 5 Annotations Every Developer Should Know
A summary of JUnit 4 & 5 annotations with examples
Before writing this article, I only knew a few commonly used JUnit 4 annotations such as
@RunWith
@Test
@Before
@After
@BeforeClass
@AfterClass
How many times did you have to comment out a test? To my surprise, there are annotations to do just that.
@Ignore("Reason for ignoring")
@Disabled("Reason for disabling")
Well, it turns out that there are a handful of other annotations, especially in JUnit 5 that could help write better and more efficient tests.
What to expect?
In this article, I will cover the following annotations with usage examples. The purpose of this article is to introduce you to the annotation, it will not go into greater details of each annotation.
Please feel free to check out the code examples used in this article in the following Github repository.