I think it is extremely cool that with a simple tag at the beginning of an individual Junit test, the entire execution of the entire collection of unit tests in a given source file. When reading about tags such as @BeforeEach and @BeforeAll after going over it briefly in class, I came across an article which describes the most common tags used for Junit tests, found here: https://www.testingexcellence.com/junit-5-annotations/.
Some of these tags are repeats from what we have discussed in lectures, but I find it helpful to rephrase the functions of each tag so that I better understand what each of them does.
@Test – This is a broad tag which simply denotes the presence of a Junit test method to be executed. There are no parameters for this tag.
@ParameterizedTest – This tag specifies that the test being executed must be run multiple times, but with different arguments each time. The test method is defined in the same way it would be under a @Test tag. However, along with the switch to a @ParameterizedTest tag at the beginning of the method, the tag @ValueSource is also used below this initial header. The attributes for this ValueSource tag denote the different arguments to be used and consumed by the test method.
@RepeatedTest – This tag describes a test method being executed a given number of times, specified in the attribute field of the tag. The difference between this tag and the @ParameterizedTest tag is that the same arguments are used for the @RepeatedTest.
@DisplayName – This tag allows the given test method to have a custom display name, which is shown by test reports and during runs. The name (as a string) is the single argument of the tag.
The next few tags affect the order that test methods are executed. Each of them are pretty self-explanatory.
@BeforeEach – With this tag, the specified method will be executed before each of the other test methods.
@AfterEach – Likewise, the method with this tag will be executed after each of the other test methods.
@BeforeAll – This tag denotes a test method being executed first in the order of all of the test methods.
@AfterAll – This tag denotes a method being executed last in the order of all of the test methods.
@Tag – This tag allows filtering or grouping of test methods by adding a custom tag name for its argument.
@Disabled – This tag causes its test method to be skipped.
While there are certainly more annotations in these Junit tests, I’m glad to learn the common tags for further testing in my Software Testing course.