Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to state expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem having non-strict mocks was almost never a problem. And new frameworks came along that state the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: "Arrange - Act - Assert" (or if you prefer, "Given - When - Then"). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated:
The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact.
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to state expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that state the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: "Arrange - Act - Assert" (or if you prefer, "Given - When - Then"). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated:
The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact.
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to state expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that state the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: "Arrange - Act - Assert" (or if you prefer, "Given - When - Then"). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated:
The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact.
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to state expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that state the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: Arrange"Arrange - Act - AssertAssert" (or if you prefer, Given"Given - When - ThenThen"). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated: "The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact."
The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact.
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to state expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that state the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: Arrange - Act - Assert (or if you prefer, Given - When - Then). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated: "The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact."
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to state expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that state the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: "Arrange - Act - Assert" (or if you prefer, "Given - When - Then"). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated:
The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact.
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to declarestate expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that declarestate the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: Arrange - Act - Assert (or if you prefer, Given - When - Then). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated: "The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact."
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to declare expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that declare the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: Arrange - Act - Assert (or if you prefer, Given - When - Then). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated: "The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact."
Go with #3, "Create a nice mock for mockOperationQueue
." The only reason you're having to do that stubbing is that OCMock creates "strict" mocks by default. Strict mocks used to be the standard, but mock object frameworks have evolved. The problem with strict mocking is that they make tests more brittle.
For example, let's say you find the need to add another "this needs to happen when I'm setting up the operation queue" call. Suddenly, your tests will break, because the strict mock will complain, "I don't know what this new call is." You've coded things well by setting up the mock operation queue in one place, so fixing it wouldn't be hard; you'd just add another stub in your -setUp
. But the test failure isn't a failure; it's noise.
OCMock was originally written when strict mocks were the norm. It was also the norm then to state expectations first, call the method of interest, then ask the mock to verify itself:
[mockView expect] addTweet:[OCMArg any];
[controller displayTweets];
[mockView verify];
But mock object frameworks have evolved since then. People figured out that having non-strict mocks was almost never a problem. And new frameworks came along that state the expectation after calling the method of interest. Using OCMockito, the example above changes to:
[controller displayTweets];
[verify(mockView) addTweet:anything()];
This restores the standard order of unit tests: Arrange - Act - Assert (or if you prefer, Given - When - Then). The verification of expectations now happens in the Assert phase, rather than sitting up in the Arrange phase. So now the test code reads more naturally, like a DSL.
The author of OCMock recognizes the importance of this evolution, and has stated: "The next major version of OCMock is planned to support nice-by-default and verification of specific calls after the fact."
- 174
- 4