-4

Please, how can I write a junit test cases for these methods :

public void setDishProvider(DishProvider dishProvider) {
        this.dishProvider= dishProvider;
        dishProvider.addDishListener(this);
    }




public int peopleHelped() {
        return counter; //returns the counter..
    }
4

1 回答 1

0

guessing blindly...

@Test
public void testSetDishProvider() {
    YourClass yourclass = new YourClass();
    DishProvider dishProvider = new DishProvider();

    yourClass.setDishProvider(dishProvider);

    assertEquals(dishProvider, yourClass.getDishProvider());
    assertTrue(dishProvider.getListeners().contains(yourClass));
}
于 2013-04-24T11:33:50.813 回答