Problem:
obs2ioda currently lacks a unit testing framework, which makes it challenging to ensure ongoing code stability as the code evolves. This gap increases the risk of unnoticed issues, such as a recent array out-of-bounds bug that went undetected for over a year. Without unit tests, developers also lack a mechanism to validate new features or bug fixes, making it difficult to enforce good software design practices.
Solution:
This PR integrates the pFUnit framework for Fortran unit testing, providing developers with the ability to create and run unit tests for existing and new code. An example test is included to demonstrate how pFUnit could have caught a recent array out-of-bounds error. To avoid impacting the majority of obs2ioda users, pFUnit is added as an optional dependency, required only for those building and running tests. While pFUnit installation is generally straightforward, there may be minor complications in environments with multiple versions of gptl. Clear guidance on installation is provided to mitigate these risks.
TESTS CONDUCTED:
Verified that example test detects intentional errors, confirming functionality.
Confirmed that pFUnit dependency does not interfere with normal obs2ioda usage.
Tested pFUnit installation in various environments to ensure manageable setup.
The addition of pFUnit as a testing framework strengthens code stability and enforces testable, modular code, benefiting the obs2ioda development workflow and quality assurance.
TYPE: enhancement
KEYWORDS: pfunit, testing, stability
SOURCE: internal
DESCRIPTION OF CHANGES:
Problem: obs2ioda currently lacks a unit testing framework, which makes it challenging to ensure ongoing code stability as the code evolves. This gap increases the risk of unnoticed issues, such as a recent array out-of-bounds bug that went undetected for over a year. Without unit tests, developers also lack a mechanism to validate new features or bug fixes, making it difficult to enforce good software design practices.
Solution: This PR integrates the pFUnit framework for Fortran unit testing, providing developers with the ability to create and run unit tests for existing and new code. An example test is included to demonstrate how pFUnit could have caught a recent array out-of-bounds error. To avoid impacting the majority of obs2ioda users, pFUnit is added as an optional dependency, required only for those building and running tests. While pFUnit installation is generally straightforward, there may be minor complications in environments with multiple versions of gptl. Clear guidance on installation is provided to mitigate these risks.
TESTS CONDUCTED:
The addition of pFUnit as a testing framework strengthens code stability and enforces testable, modular code, benefiting the obs2ioda development workflow and quality assurance.