I am trying to write test case for an objective-C function that uses a C++ function with return type bool. Inside the Objective-C function, I am simply calling the C++ function in a conditional statement as if(CppClass::CppFunction) and proceeding accordingly. For writing the test for the said objective-C function, I need to mock the CppFunction. I am not able to do that with OCMock. What is the correct way of mocking the C++ function?
How to mock a C++ function in Objective C testing
288 Views Asked by Brainfreeze At
1
There are 1 best solutions below
Related Questions in C++
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Why can't I use templates members in its specialization?
- How to fix "Access violation executing location" when using GLFW and GLAD
- Dynamic array of structures in C++/ cannot fill a dynamic array of doubles in structure from dynamic array of structures
- How do I apply the interface concept with the base-class in design?
- File refuses to compile std::erase() even if using -std=g++23
- How can I do a successful map when the number of elements to be mapped is not consistent in Thrust C++
- Can std::bit_cast be applied to an empty object?
- Unexpected inter-thread happens-before relationships from relaxed memory ordering
- How i can move element of dynamic vector in argument of function push_back for dynamic vector
- Brick Breaker Ball Bounce
- Thread-safe lock-free min where both operands can change c++
- Watchdog Timer Reset on ESP32 using Webservers
- How to solve compiler error: no matching function for call to 'dmhFS::dmhFS()' in my case?
- Conda CMAKE CXX Compiler error while compiling Pytorch
Related Questions in OBJECTIVE-C
- How to control the volume of an iPhone programmatically in objective-c
- Occasional crash at NSURLSessionDataTask dataTaskWithRequest:completionHandler:
- How to set value the descriptor of iOS BLE in Objective-C?
- Unexpected #selector() Behavior in Swift-Objective-C Interop?
- In what context can we use an unqualified #selector() expression in Swift?
- AVPictureInPictureController crashes during initialization
- How to use pow() in Objective-C?
- How to change the image on the MGSwipeButton in MGSwipeTableCell
- Using sort descriptors in Outline View
- Why is my Swift function not printing from inside the dataTask closure?
- Using UICollectionViewCell with IBOutlet
- Undefined symbol: _OBJC_CLASS_$_ only on simulator
- Why can't I receive a notification sent from Camera Extension(Swift) to an observer application (obj-c++)
- Behavior of __block modifier in objc
- Inserting subview into view where I've added subviews and sublayers
Related Questions in UNIT-TESTING
- Google Truth.assertThat.contains does not behave similar to List.contains
- What's the best way to breakup a large test in pytest
- How to refer to the filepath of test data in test sourcecode?
- How to mock a dynamic endpoint in Apache Camel Spring Boot
- pytest mock failing when mocking function from imported package
- Jest configuration error while running test case in teamcity
- Resolve paths dynamically based on directory where test (or tested files) is located in Jest
- One-time implementation with Jest's mockResolvedValueOnce within test remains from one test to another
- Why can't I mock the decorator of the function?
- Gitlab pipeline stuck with nx cloud issue
- How to create an improperly closed gzip file using python?
- Nest.js service structure for API integration
- uiState not updating in Tests
- Unit Tests not Compiling or Being found without mod tests in main.rs. Is this a requirement or am I missing some configuration?
- Mocking Stream or Reader in Java Junit
Related Questions in MOCKITO
- How to use Mockito for WebClient get call?
- How to return a real object from a mocked construction with Mockito
- Springboot Mockito - problem with mocking
- Where I use @ExtendsWith(MockitoExtension.class) and @SpringBootTest anyone clarify me with example
- Junit test: NoSuchElementException, Mock getConnection
- Junit test with Mockito: Error ExceptionInInitializerError
- How to Mock HttpResponse
- How do you mock generic types in a type-safe manner?
- MaterialButtonToggleGroup Toggles Not Visible During Android Espresso Tests
- Mockito it's instantiating with null the builder in the mocked class
- How to mock dependency in service class from Junit
- classNotPreparedForTest exception, using JUNIT5, MOCKITO and POWERMOCKITO
- Mock DriverManager.getconnection method for junit/mockito unit tests
- How to set environment variable in springboot integration junit test case
- (junit/mockito) thread.join() is completed before thread work is done?
Related Questions in OCMOCK
- Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_OCMArg"
- [OCMock]A question about the andDo function
- [OCMock][OCMProtocolMock][OCMStub]When I OCMProtocolMock a protocol(This protocol has a method),How can I invoke the real implementation of the method
- [OCMock][OCMVerify]Why does OCMVerify still pass when I don’t call a method?
- OCMVerify crashes test after a mocked callback
- Did not record an invocation in OCMStub/OCMExpect/OCMReject
- Test if a function is called in Unit Testing for Objective C
- In Objective-C, how can I make a typedef for a composed object?
- 'OCMock/OCMockObject.h' file not found
- Proper usage of OCMock with Singleton
- How to mock a C++ function in Objective C testing
- OCMock test if method does nothing but is called
- How can I get a nested objective-c async method to execute under test using mocks and expectations?
- OCMock/OCMVerify - Expression result unused
- OCMock for dispatch_async without callback
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
This might be overkill if you're really just trying to mock one C++ function, but you can try using Mimicc
Run it on the header which declares the C++ code you want to mock and pass the same command line arguments that you would to the clang invocation you use to compile the code.