-
Notifications
You must be signed in to change notification settings - Fork 96
Test Doubles vs Hook
coolxv edited this page May 9, 2026
·
1 revision
| Problem | Solution Category |
|---|---|
| Who executes the logic? | Test Doubles |
| How is execution redirected? | Hook / Detour / Trampoline |
| Type | Core Idea | Main Purpose | Typical Behavior |
|---|---|---|---|
| Dummy | Placeholder object | Fill required parameters | Never actually used |
| Stub | Returns predefined data | Control inputs | Returns fixed values |
| Mock | Verifies interactions | Validate behavior/contracts | Checks calls, arguments, order |
| Spy | Records calls | Observe interactions later | Stores call history |
| Fake | Simplified working implementation | Replace real systems | Contains real internal logic |
| Concept | Core Idea | Main Responsibility |
|---|---|---|
| Hook | Intercept behavior | Replace or intercept execution |
| Detour | Redirect execution flow | Reroute control flow |
| Inline Hook | Patch machine code directly | Modify function entry |
| Trampoline | Preserve original execution path | Resume original function |
| Technique | Mechanism | Modifies Code Section? |
|---|---|---|
| Inline Hook | Patch function instructions | YES |
| IAT Hook | Replace import table entries | NO |
| GOT/PLT Hook | Replace ELF relocation entries | NO |
| VTable Hook | Replace virtual function pointers | NO |
| Breakpoint Hook | Use debug interrupts | NO |
| LD_PRELOAD | Dynamic linker substitution | NO |
| Category | Abstract Meaning | Key Question |
|---|---|---|
| Test Doubles | Logical substitution | “Who executes the logic?” |
| Hook / Detour | Control-flow redirection | “How is execution redirected?” |
| Trampoline | Execution-flow recovery | “How do we continue original execution?” |