How to access private function from a stub callback?
I have a private function that needs to be called normally or needs to be stubbed depending on the test case. So, I either need to be able to apply the stub of the private function only to specific test case or be able to call the original private function from within the stub callback. Anyone knows how to do either?
Best Answer
-
Hi @nokoru ,
To call the original private function from the stub callback, you need to declare your stub callback as a static member of the test suite and make sure your test configuration has the "Access to private members" instrumentation feature enabled (test configuration->Execution tab->General tab-> Instrumentation Mode-> Edit)
Stub callback functions that are added by the test cases editor are by default declared as static members of the test suite class. If you are not using the test case editor, you can try it once and select "Add New -> Stub Configuration" to see how the editor declares callbacks.
5
Answers
-
How do I go about adding stub via test case editor? I can't seem to find test case editor anywhere.
0