1import org.junit.Assert;
2import org.junit.Test;
3
4public class Test {
5
6 public static int square(int n) {
7 return n * n;
8 }
9
10 @Test
11 public void squareTest() {
12 Assert.assertEquals(25, square(5));
13 Assert.assertEquals(16, square(4));
14 Assert.assertEquals(9, square(3));
15 Assert.assertEquals(4, square(2));
16 Assert.assertEquals(1, square(1));
17 }
18}
19
1import org.junit.Assert;
2import org.junit.Test;
3
4public class Test {
5
6 public static int square(int n) {
7 return n * n;
8 }
9
10 @Test
11 public void squareTest() {
12 Assert.assertEquals(25, square(5));
13 Assert.assertEquals(16, square(4));
14 Assert.assertEquals(9, square(3));
15 Assert.assertEquals(4, square(2));
16 Assert.assertEquals(1, square(1));
17 }
18}
1-It is an open-source testing framework for java programmers.
2-Test runner support to execute the test case
3-It is one of the unit testing framework.
4-Assertion support for checking the expected result.
5-Annotation support for test cases