I'm trying to reduce the monolithicness of my code to make it into smaller/easier digestible units, but I'm not sure what the best practices are with testing. Here is an example:
def a(some_input):
...
def b(other_input):
# Bunch of logic, possible other function calls
if some_condition:
a(...)
Testing a seems straightforward to me, but when it comes to b, should I be testing that when b is called with input that leads to it calling a calls a (in python that's something like a Mock.assert_called_with, or should I just be testing that the output is correct?
My view on this is let's say re-use a all over and break a; I think that's a bunch of false positive test failures since the surrounding logic/behavior is correct, and simply a should be fixed.
source https://stackoverflow.com/questions/71828173/should-i-be-testing-results-or-behaviors
Comments
Post a Comment