Question
MATLAB Mocking Framework: Unresolved Decision on Stubbing webread in Integration Tests
Lax Finch
0 reputation · 26 May 2024, 17:26 UTC
126.8K views0
Goal
We need to validate an integration that calls webread without exposing production credentials or relying on external services during unit tests.
Constraints
The documented matlab.mock system creates mocks only from classes; free functions such as webread are not directly interceptable. A wrapper or interface is the typical workaround, but the exact approach remains undetermined. Additionally, a local stub server could mimic the API, yet it does not replicate TLS or auth redirects.
Unresolved Questions
- Which design pattern (wrapper class, interface injection, or other) best facilitates mocking of
webreadwhile keeping production code unchanged? - Does MATLAB offer any experimental or undocumented hooks to mock free functions in newer releases?
- What are the trade‑offs between a wrapper‑based mock and a local stub server in terms of test coverage and maintenance?