Hello everyone!
I am a former QA engineer (2 years professional experience - I have mostly done E2E tests), now software developer, working on a Django/React app.
I have no experience in unit testing and I have had discussions with other devs regarding unit testing. Here is my use case :
I have this django method (naming and type hints are for helping you understand the outputs):
@action(detail=False)
def my_function_to_test(self, request):
# My logic here
return custom_fuction_to_transform_as_csv(my_logic_as_dict)
# Util method used multiple times throughout my app
def custom_fuction_to_transform_as_csv(logic_to_transform: dict) -> csv_outcome_as_http_response:
# transform my dict into a csv
return HTTPResponse(csv_outcome)
While writing my unit test, I wanted to patch the custom_fuction_to_transform_as_csv
function to return the unmodified dict to only test my method logic. My thoughts were that this function should be tested separately as it is used throughout the app.
My colleague was arguing that we should test the full output of the method after being transformed into csv response.
- Do you have thoughts/experience regarding that?
- Any good ressources to recommend?
Note: Do not take the code syntax into consideration.
Thanks!
Theo