<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.0</version>
<scope>test</scope>
</dependency>
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class MyLibraryTest {
@Test
void testAddition() {
int result = MyLibrary.add(2, 3);
assertEquals(5, result);
}
@Test
void testSubtraction() {
int result = MyLibrary.subtract(5, 3);
assertEquals(2, result);
}
}
shell
mvn test
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running MyLibraryTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 s
[INFO]
[INFO] Results :
[INFO]
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0