-
Notifications
You must be signed in to change notification settings - Fork 0
arstrube/FakeClass
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
RUNTIME-SELECTABLE CPPUTEST FAKE CLASS EXAMPLE Sometimes it is desirable to test a module itself, then fake it out for something else to be tested, all in the same test executable. This cannot be done via linker substitution. The following is a very basic example of how to set up fake classes that can be swapped at run-time. The assumption is that the code to be tested is written in pure C. Our fake classes, on the other hand, work by harnessing the full power of object-oriented design and the C++ language. I have tried to keep everything as simple as possible. Used.c - C Module that other code depends on User.c - C Module that depends on the above UsedFake.cpp - Class that lets you choose at run-time whether mocks, stubs, dummies or the real implementation will be called for the Used module. RunAllTests.cpp - Unit tests that test-drive all of the above and demonstrate how to use it. This is just a very basic example; no guarantees for usefulness or anything! Use as a template for building your own fake classes. (c) 2014 Arnd R. Strube
About
An example for a generic fake class for use with CppUTest. This will allow choosing stubs, mocks, dummies or original code at run time. Use it as a template to create your own.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published