NRLMMD-GEOIPS / geoips

Main Geolocated Information Processing System code base with basic functionality enabled.
https://nrlmmd-geoips.github.io/geoips/
Other
15 stars 12 forks source link

Refactor Unit Tests to not require any test data #673

Open evrose54 opened 4 months ago

evrose54 commented 4 months ago

Requested Update

Description

It was discussed in #670 that we should remove or refactor any unit test which makes use of data files. This could be test data, or any other data that is unlikely to be available to the CI. This change should occur for two reasons.

  1. Any unit test that makes use of a data file is likely to be much slower than a unit test that does not make use of a data file.
  2. Using data in a unit test is more of an integration test than anything. Unit tests should only check the integrity of the code, not what it does to a data file.

If you find yourself unable to test some code without a data file, it is likely that the code needs to be refactored into smaller portions that can be tested without data.

Background and Motivation

This issue stems from this comment on #670.

Code to demonstrate issue

Checklist for Completion

jsolbrig commented 4 months ago

As a note: It is perfectly fine to create fake data for testing particular functions. For example, you might want to create test data for testing the functions that generate latitude, longitude, satellite zenith angle, etc. by extracting a little data from a file. You could take a small bit of data from a file, hard-code it into the tests, then run the function and test the expected result.