Verify setup and teardown using JUnit lifecycle hooks
Preconditions (2)
Step 1: Create a test class CalculatorTest
Step 2: Use @BeforeEach to initialize a Calculator object before each test
Step 3: Write a test method testAdd that adds two numbers and asserts the result
Step 4: Write a test method testSubtract that subtracts two numbers and asserts the result
Step 5: Use @AfterEach to set the Calculator object to null after each test
Step 6: Run the tests and observe that setup runs before each test and teardown runs after each test
✅ Expected Result: Each test method runs with a fresh Calculator instance initialized by @BeforeEach, and after each test the Calculator reference is cleared by @AfterEach. Tests pass successfully.