mardi 16 juillet 2019

How should I test functions that call other functions?

def task_completed(task: Task) -> None:
  _update_status(task, TaskStatus.COMPLETED)
  _process_task(task)


def task_canceled(task: Task) -> None:
  _update_status(task, TaskStatus.CANCELED)
  _process_task(task)

# ...

def _process_task(task: Task) -> None:
  send_notification(task)  # already tested
  cleanup(task)  # already tested

I have written tests for the "public" functions send_notification and cleanup. Since I defined _process_task as a "private" function I don't write a test for this one.

How should I write tests for the functions: task_completed and task_canceled

Both functions are calling the _process_task function which calls the functions send_notification and cleanup which I've already tested.

Should I just test if these two "public" functions are called or should I test everything again what theses two functions are actually doing?

Aucun commentaire:

Enregistrer un commentaire