dimanche 28 mai 2017

How to test getter that returns a list of custom objects?

Ok so lets say we have the following simple class:

 public class Employees{


        List<Person> personsList;
        private int numberOfEmployees;

        public void Employees(){

        //constructor

        }

        //getters & setters

        public List<Person> getPersons(){
            return personsList;
        }

          public void addNewEmployee(Employee employee){

        this.numberOfEmployees.add(employee);

    }

    }

And i want to test the getter that returns a list of Person objects(using mockito)

I am doing something like:

@Test
public void getPersonsTest() throws Exception{
    Employees.addNewEmployee(employee); //where employee is a mocked object

    assertEquals(Employees.getPersons(),WHAT SHOULD I PUT HERE??);


}

Any ideas?

Aucun commentaire:

Enregistrer un commentaire