Code coverage doesn't tell you everything. In this case you'll get 100% line coverage for factorial(3)
but it won't cover all "cases".
When testing a recursive function you'd want to test various cases:
- Each of the base cases.
- The recursive cases.
- Incorrect input (e.g., negative numbers).
- Any function-specific edge cases.
You can test less but you'll leave yourself open for potential bugs when the code is changed in the future.