Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Stubbing out Internal Functions inside Static Library

choner22
choner22 Posts: 15

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

  • Mirek
    Mirek Posts: 141 admin

    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.