Comments (3)
You need to make the A member accessible in the test so that you can place an expectation on it. One traditional technique for this is dependency injection, i.e. you create your B with the mocked A for the test.
from trompeloeil.
Yeah, I know what you mean, but that's a real huge workload, because there's a lot of historical code (T_T). And they are running at product....
So, i want to found some solution that can integrated unit testing without requiring too many source code changes。
There are many codes like demo in historical code。Although not the best, but it work。 So i can not change every class to dependency injection。
Thanks。
from trompeloeil.
Well, the library can only work within the rules of the language. For this to work you need:
- To ensure that in the test, the member m_pObj points to a mock object.
- Access to the mock object from the test code, and its type known, at compile time, in the test to be a mock.
With those you can place expectations on the mock and test your code. If those are not acceptable, then I'm afraid I cannot help.
from trompeloeil.
Related Issues (20)
- CMake version required not correct HOT 5
- Setting expectations in a function fails HOT 6
- how can I mock the static member function and non-virtual member fuctions? HOT 2
- Problematic traits for ``streamer`` primary template HOT 4
- Documentation, typo and missing bits and bobs HOT 3
- Compile error when returning values from a tl::expected with a void expected value HOT 5
- Refactoring with sequenced expectations HOT 2
- Build for QNX tests fail due to catch2 header file HOT 1
- Wrong Expectaition message HOT 1
- [Bug] Fails to run tests with catch 3.x HOT 4
- Tests fail to compile: error: 'ret_count' is an unsafe buffer that does not perform bounds checks HOT 4
- Expect call returning a reference HOT 2
- can this cppcheck inline suppression be added HOT 1
- unreal engine support & noreturn/std::abort HOT 3
- Setting side effects after creating expectactions (inside DOCTEST_SUBCASEs) HOT 5
- Feature Request: Allow specifying calling convention attributes to Mock methods HOT 12
- Spy some dependencies HOT 3
- ``trompeloeil_movable_mock`` only provides move-ctor HOT 3
- Warnings with gcc's -Weffc++ HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trompeloeil.