Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    How is this being upvoted, this goes totally against the actual question at hand. Commented Aug 18, 2020 at 3:43
  • @TristanMaxson really? Nothing in the requirements given asked us to maintain the current lion behavior. We're free to make an animal that does whatever we like when it's told to eat so long as it counts meals and uses the same interface. In fact every answer here followed this answers method of overriding the behavior. Which is fine. Since it's a test I stuck with a simple mock. Others wanted to show off the decorator pattern. Which also works. Commented Aug 18, 2020 at 7:30
  • 1
    @TristanMaxson the question asks to maintain the interface and the class. Namely, I read that as the Animal interface and the Lion class. This answer changes neither, so I don't see how it's failing the requirement. Commented Aug 18, 2020 at 7:59
  • 1
    Anyway, decorator or mock, what ends up getting tested isn't Lion. These answers test the lion.eat() calling code. In it's current form, not really worth testing. Commented Aug 18, 2020 at 8:13
  • 1
    @VLAZ no it doesn't anymore, since candied_orange did a sneaky edit ;) Commented Aug 18, 2020 at 8:15