|
FhSim
3.1.0
Marine systems simulation
|
FhSim tests are based on GoogleTest. For simulation-oriented tests (especially for external SimObject/plugin projects), use FhSim::fhsim_test.
For full API and reference-mode behavior, see Test Tools Library.
Recommended layout:
Create one fhsim::test::TestRuntimeConfig and store it where tests can access it (project-local helper, fixture singleton, or equivalent).
Typical mapping:
testDir = argv[1]inPath = <testDir>/inresPath = <testDir>/outlogPath = <testDir>/outrunPath = current working directorylogLevelToScreen/logLevelToLog from CLI argsThis is the same pattern used by FhSim core tests (tests/core/fhSim/Run_test.cpp).
When a test needs to check specific numeric values (not just regression comparison against a reference file), use CapturingObserver instead of reading result.output.
CapturingObserver collects snapshots in memory and provides named lookup via OutputAt (output port values from the XML output spec) and StateAt (raw ODE state values). For most tests, OutputAt and FinalOutput are the right choice: they access the same values that the CSV result file captures.
See the CapturingObserver section in Test Tools Library for the full API and the OutputAt vs StateAt decision table.
TestSpec::jacobianMode controls Jacobian validation in RunTest:
No: do not run Jacobian check.Auto (default): run Jacobian check when Jacobians are available, otherwise skip.Yes: require Jacobian check; failures make the test fail.Example:
When Jacobian check runs, inspect result.jacobian for detailed diagnostics.
When spec.diagnosticsJsonPath is set, RunTest writes a diagnostics JSON artifact only when diagnostics are enabled in the model input (for example by adding <Diagnostics/> under <Integrator>).
Build with tests enabled (for Conan setups: -c tools.build:skip_tests=False). Then run the produced test executable from its build output directory.
For external SimObject libraries, ensure SFH_LICENSE_FILE points to a valid license file before running tests.