Comments (3)
So after a short investigation I found that I understood the whole concept of mocking in a bad way. The behavior I thought to be invalid is indeed valid - mock object doesn't forward messages to an underlying instance, it's a job for partial mocks, that are not yet implemented, right?
from ocmockito.
Correct, partial mocks aren't implemented yet. But beware, partial mocking can be a code smell. In your case, what you're trying to specify seems too restrictive. Try to think in terms of observable effects, and you may find there's no need for a mock at all. For example:
- (void)testLessonShouldHaveGivenName
{
// given
LessonModel *lesson = [LessonModel lessonWithName:@"NAME"];
// then
assertThat([lesson name], is(@"NAME"));
}
In other words, don't write a test that one method calls another within its own class. That only leads to fragile, overspecified tests that keep code from being flexible. Instead, call the method and test that it does the right thing. Use mocks only for things that are too expensive or unreliable (like database or network access) or for systems you don't own (like Cocoa singletons).
from ocmockito.
Thank you!
from ocmockito.
Related Issues (20)
- Swift Static Declaration of 'times' follows non-static declaration HOT 1
- Expected nil, but was nil HOT 3
- Crash when calling mocks from `dealloc` that are not called from elsewhere HOT 16
- MKTArgumentCaptor to HCArgumentCaptor migration HOT 2
- verify macro replaces argument type with id HOT 2
- Unable to @import OCMockitoIOS HOT 4
- Is there a way to assert method throws? HOT 1
- Stubbing the protocol return as Nil HOT 3
- Cannot use OCMockito because of OCHamcrest. HOT 2
- Feature request: possibility to call through HOT 1
- Argument captor capturing outer function HOT 1
- Import OCHamcrest as a module breaks backward compatibility and feels unnecessary HOT 1
- Mock internal calls of a another class methods HOT 4
- Feature Request: Apple Silicon binary release HOT 9
- Catalyst Support for OCMockito.xcframework HOT 8
- verify doesn't fail when parameter is mocked HOT 11
- Stubs return nil when verifying HOT 3
- Could not build OCMockito using Carthage HOT 3
- Building with Carthage fails HOT 1
- Use OCHamcrest 9.0.1 via all dependency managers
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 ocmockito.