unit test is a practice by which small units of code are tested.Given some contextWhen some action is carried outThen consequences should be observable// Given
String name = "Leon";
Integer age = 25;
Person leon = new Person(name, age);
// When
String getNameResult = leon.getName();
Integer getAgeResult = leon.getAge();
// Then
Assert.assertEquals(name, getNameResult);
Assert.assertEquals(age, getAgeResult);
Given is the section of a unit test method that
Example
// Given
String name = "Leon";
Integer age = 25;
Person leon = new Person(name, age);
When is the section of a unit test method that
// When
String getNameResult = leon.getName();
Integer getAgeResult = leon.getAge();
Then is the section of a unit test method that
// Then
Assert.assertEquals(name, getNameResult);
Assert.assertEquals(age, getAgeResult);