I'm trying to test a void method using JUnit in NetBeans, my method is changing the value of a double variable and then print the new variable's valur into a TextField, this is my method :
private void calcul(){
if(operateur.equals("+")){
chiffre1 = chiffre1 + Double.valueOf(ecran.getText()).doubleValue();
ecran.setText(String.valueOf(chiffre1));
}
if(operateur.equals("-")){
chiffre1 = chiffre1 - Double.valueOf(ecran.getText()).doubleValue();
ecran.setText(String.valueOf(chiffre1));
}
if(operateur.equals("*")){
chiffre1 = chiffre1 * Double.valueOf(ecran.getText()).doubleValue();
ecran.setText(String.valueOf(chiffre1));
}
if(operateur.equals("/")){
try{
chiffre1 = chiffre1 / Double.valueOf(ecran.getText()).doubleValue();
ecran.setText(String.valueOf(chiffre1));
} catch(DivisionSurZeroException e) {
ecran.setText("0");
}
}
}
I Googled about how to test void method but all I can find is void methods that changes the size of a collection.
So please can you give me some idea to start with ? I really don't know what to start with.