Modern Fortran test frameworks

Regardless of programming language, we feel that unit test frameworks should be lightweight so that it’s not burdensome to setup and maintain, so that end users can easily run the unit and integration tests themselves as part of a typical end-user install. Two Fortran unit test frameworks meeting these principles are Zofu and Vegetables.

A third option is to write small test programs and execute them using CMake or Meson. This method can also be an appropriate choice where the program uses complex library interactions that may not mix well with a generic test framework. Although it would perhaps be more robust to use a formal test framework, developer time limitations can also be a concern.

Zofu

Zofu uses CMake or Meson. Zofu is typically installed and then “found” by the main project’s CMake or Meson scripts. Then, meson test or ctest is used to execute the numerous small test programs generated in Zofu.

Vegetables

The Vegetables Fortran test framework requires fpm as other prerequisites are auto-downloaded and installed via fpm. If the Fortran project doesn’t use fpm, you might need to consider Zofu instead.