Testing Strategies for OpenFOAM Projects
DOI:
https://doi.org/10.51560/ofj.v5.134Keywords:
unitTesting, Catch2Abstract
While testing is increasingly recognized as essential in scientific software development, it is not yet standard practice within the OpenFOAM community for developing new solvers and features. This gap stems partly from the challenges of integrating testing into typical OpenFOAM workflows and limited guidance on implementing effective tests. Writing tests for complex software like OpenFOAM based projects presents unique obstacles, including difficulty in configuring tests for various cases. This paper addresses these issues by discussing established test types in the context of OpenFOAM, identifying common challenges in developing tests for this platform, and suggesting best practices to enhance the testability of code based on OpenFOAM. Detailed guidance is provided for integrating the Catch2 unit test framework, alongside two new tools: the foamUT framework and the OpenFOAM Benchmark Runner (OBR), which facilitate unit and integration testing. To illustrate these tools in practice, we present three case studies. The first demonstrates the direct integration of Catch2 in the WENOExt project, showcasing test case creation and its synergy with OpenFOAM projects. The second introduces the foamUT framework, which simplifies Catch2 integration for OpenFOAM projects. Finally, the OBR framework is used for benchmarking and integration tests in the OpenFOAM Ginkgo layer. Additionally, we discuss the current state of testing in OpenFOAM and emphasize the need for more comprehensive testing practices within this community, particularly with libraries such as Catch2. Overall, this paper serves as a practical introduction to unit and integration testing for OpenFOAM developers and introduces new tools that lower the barrier to entry, improve test suite robustness, and simplify unit test integration.

Downloads
Additional Files
Published
Issue
Section
License
Copyright (c) 2025 Jan Wilhelm Gärtner, Gregor Olenik, Mohammed Elwardi Fadeli, Lukas Petermann, Andreas Kronenburg, Holger Marschall, Hartwig Anzt

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.