I need to write 5 different unit test for the scenario below. How can I achieve that? I am poor on testing so your help will be really appreciated. Thanks in advance.
This is class for doing the sorting of three number.
public class SortNumber {
public double[] Sort3(double value1, double value2, double value3) {
double sorted[] = new double[3];
if(value1>=value2 && value1>=value3) {
sorted[2] = value1;
if(value2<=value3) {
sorted[0] = value2;
sorted[1] = value3;
}
else {
sorted[0] = value3;
sorted[1] = value2;
}
}
else if (value2>=value1 && value2>=value3) {
sorted[2] = value2;
if(value1<=value3) {
sorted[0] = value1;
sorted[1] = value3;
}
else {
sorted[0] = value3;
sorted[1] = value1;
}
}
else {
sorted[2] = value3;
if (value2<=value1) {
sorted[0] = value2;
sorted[1] = value1;
}
else {
sorted[0] = value1;
sorted[1] = value2;
}
}
return sorted;
}
}
Class below contains main method:
public class Calculate {
public static void main(String[] args) {
SortNumber sn = new SortNumber();
sn.Sort3(44, 5, 100);
}
}
Aucun commentaire:
Enregistrer un commentaire