0

Suppose I want to unit test the following abstract class:

abstract class Fruit {

  private int calories;

  public Fruit(int calories) {
    this.calories = calories;
  }

  int getCalories() {
    return this.calories;
  }

  double getKilojoules() {
    return this.calories * 4.184;
  }
}

I agree that abstract classes and interfaces should not be tested - their implementations should, but what about concretely defined methods like simple getters like getCalories()?

Now some say that simple methods like getters should not be tested, but even then: what about methods like getKilojoules()?

Sam Bokai
  • 538
  • 1
  • 5
  • 13

0 Answers0