Search⌘ K
AI Features

@Test Annotation

Explore how to apply the JUnit 5 @Test annotation to mark methods as test cases. Understand setting up test scenarios for a sample method that checks if a number is even or odd. Practice writing test methods with assertTrue and assertFalse to verify expected outcomes and run your tests successfully.

Class Under Test

Let’s first create a class with some functionality to test. This class will have the method for which we will write our test scenarios to demonstrate the @Test annotation’s usability. The class name in our example would be - OddEven, as shown in the code below.

Method Under Test

Inside OddEven class, let’s create a method by name isEvenNumber(). This method will take in an integer value and return a boolean value that whether the ...