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*

11
  • 4
    Well, one of the points is, that by mocking / unit-testing it, you can isolate any problems to your code. If an integration test fails, you are unaware as to whose code is broken, yours, or the API. Commented Jun 6, 2016 at 10:45
  • 9
    Only four tests? You have six boundary ages you should be testing: 17, 18, 19, 20, 21, 22... ;) Commented Jun 6, 2016 at 10:48
  • 23
    @FilipBartuzi, I assume the method is checking whether a male is over 21 for example? As currently written, it doesn't do that, it is only true if they are 22+. "Over 21" in English though means "21+". So there is a bug in your code. Such bugs are captured by testing boundary values, ie 20, 21, 22 for a male, 17,18,19 for a female in this case. So at least six tests are needed. Commented Jun 6, 2016 at 10:54
  • 7
    Not to mention the cases of 0 and -1. What does it mean for a person to be -1 years old? What should your code do if your API returns something nonsensical? Commented Jun 6, 2016 at 13:36
  • 11
    This would be a lot easier to test if you passed a person object as the parameter. Commented Jun 6, 2016 at 13:42