jeudi 28 mars 2019

Junit test for Loop

I am teaching myself Junit testing and I am struggling to create a test for the following code

 private ArrayList<AirbnbListing> List;

   public int getAvgReviews(){
    int sums = 0;
    for (int i = 0 ; i < List.size(); i++){
        AirbnbListing houses = List.get(i);
        if(houses.getPrice() >= fromValue && houses.getPrice() <= toValue){
            sums += houses.getNumberOfReviews();
        }
    }
    return (sums/getNoOfProperties());
}

Can someone help me out

Aucun commentaire:

Enregistrer un commentaire