Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing exercise - um2nc callback_function() #45

Open
10 tasks
truth-quark opened this issue Jun 25, 2024 · 0 comments
Open
10 tasks

Unit testing exercise - um2nc callback_function() #45

truth-quark opened this issue Jun 25, 2024 · 0 comments
Assignees

Comments

@truth-quark
Copy link
Collaborator

truth-quark commented Jun 25, 2024

As an initial unit testing exercise, let's start with a standalone function with only inputs/outputs. The um2nc callback_function() is a good one to try: https://github.com/ACCESS-NRI/amami/blob/main/amami/parsers/um2nc_parser.py#L33-L74

Let's split this into parts, so reviews/feedback can be staged between task blocks.

Bonus questions for reviews:

  • What was easy?
  • What was hard?
  • What doesn't work?
  • Any general comments or observations?

Part 1 Tasks - Initial unit testing (retrofitting style):

  • Configure environment so pytest can be run from the command line & IDE
  • Write a unit test to exercise a "good" path through the function & assert the output is correct
  • Write a test to go through a failure path
  • All tests pass

Can check & review here.

Part 2 Tasks - More unit testing for coverage:

  • Write tests such that all good code paths are run through.
  • Add tests to cover all failing paths.
  • Aim for 100% code coverage.
  • All tests pass

Check & review here too.

Part 3 Tasks - Unit testing supporting refactoring:

  • Experiment with simplifying & restructuring the code. Can much the code be simplified?

Final wrap up

  • Compare old & new side by side (count SLOC, compare readability/clarity/simplicity)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants