Stubbing out Internal Functions inside Static Library

choner22choner22 Posts: 9

My code under test calls another function, I'll call function A. Function A lives in a linked in static library called SL. Function A inside SL calls Function B directly which also lives in SL. I want to stub the call to function B. In this configuration, is this possible?

In more general terms, can I stub an internal function inside a linked in static library that only gets called via other functions inside the same static library? Is there a limitation here in the Unit Testing Framework?

Comments

  • MirekMirek Posts: 39

    If function B lives in the same static library (SL) as function A, then at this moment it is not possible to stub out the call A->B. Stubs are applied through the source code instrumentation, and in case of a library, we are dealing with the binary code. Specific situation is when the target function (called function) definition does not exist (or definition is not visible for specific configuration) in such case C++test stubbing framework can add a stub function which will be used even inside libraries connected to the test setup.

Sign In or Register to comment.