import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class CalculatorTest {
private final Calculator calculator = new Calculator();
@Test void testAdd() { assertEquals(5, calculator.add(2, 3), "2 + 3 should equal 5"); assertEquals(0, calculator.add(0, 0), "0 + 0 should equal 0"); assertEquals(-1, calculator.add(2, -3), "2 + -3 should equal -1"); }
@Test void testSubtract() { assertEquals(-1, calculator.subtract(2, 3), "2 - 3 should equal -1"); assertEquals(0, calculator.subtract(3, 3), "3 - 3 should equal 0"); assertEquals(5, calculator.subtract(2, -3), "2 - -3 should equal 5"); }
}
In Java, annotations are a form of metadata that provide data about a program but are not part of the program itself. They can be used for various purposes, such as providing information to the compiler, generating code, or affecting the runtime behavior of applications.
SOURCE
, CLASS
, or RUNTIME
.java
Copy code
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
// Annotation elements
}