Skip to main content
19 events
when toggle format what by license comment
Mar 26, 2014 at 19:15 audit Close votes
Mar 26, 2014 at 19:15
Mar 17, 2014 at 16:58 history tweeted twitter.com/#!/StackProgrammer/status/445605125919612928
Mar 12, 2014 at 13:44 vote accept Songo
Mar 11, 2014 at 11:13 answer added Songo timeline score: 4
Mar 8, 2014 at 16:09 audit Close votes
Mar 8, 2014 at 16:09
Mar 6, 2014 at 13:56 audit Reopen votes
Mar 6, 2014 at 13:56
Mar 5, 2014 at 1:09 answer added MichelHenrich timeline score: 5
Mar 3, 2014 at 18:40 comment added k3b i understand your example but i donot understand why it is neccessary to verify that isvalid was called. you can have one test that expects "InvalidArgumentException" if the fake validator returns false. no need to test that validate was called.
Mar 3, 2014 at 18:30 comment added Songo @k3b This is a really really really stupid example, but believe me I have seen it in our legacy systems: phpfiddle.org/api/raw/hr4-q1e I hope this clarifies what I'm trying to solve.
Mar 3, 2014 at 18:30 comment added pdr Most frameworks, nowadays, have a Verify method that can be called after the method under test. So you stub to get your canned response, regardless of the input, and then verify that the right input was given. This confirms more closely to Arrange-Act-Assert AND removes this confusion between stubbing and mocking.
Mar 3, 2014 at 17:51 comment added k3b can you give an example why it is important that validate was called once? I can only imagine tests where stubs are sufficient. Example: having an orderclass that uses an addressvalidation service and the order should only be possible if the billing address is valid. so i have one test where validate returns true and one where validate returns false
Mar 3, 2014 at 17:31 comment added Songo @RobertHarvey I see what you mean. We aren't blindly trying to follow a dogma for unit testing. We are still trying to find the correct way to proceed. That's why we do code review sessions in the first place :) We have very limited access to unit testing or TDD expertise on site so most of us are trying to contribute by self study or open discussions during code review sessions. Nobody holds the "I read it then it's correct" attitude it's more like "I haven't seen it before, what's ur resource?"
Mar 3, 2014 at 17:18 comment added Songo @RobertHarvey I have never seen a fake object used that way in a unit testing or TDD book (we r new to TDD btw). It seems like we are mixing the usage of Stubs with Mocks when the intent of each of them is different, however, I can't see how I would have 100% confidence in my test otherwise.
Mar 3, 2014 at 17:18 comment added Songo @RobertHarvey well yea it's working. However, just coz it's working doesn't mean it's a good practice or maintainable.
Mar 3, 2014 at 16:45 answer added Sebastian Redl timeline score: 5
Mar 3, 2014 at 16:31 comment added Robert Harvey What do you mean by "correct?" How would we determine that our answer is "correct?" In the code review, what was the specific objection to using a "stock?" Does the stock work anyway (i.e. does it fulfill the desired testing objective), despite the reviewers' objections?
Mar 3, 2014 at 16:28 comment added Songo @JohnRaya yup, I only used PHP for demonstrating my idea. This is more of a design question. Feel free to reply in the language you prefer.
Mar 3, 2014 at 16:26 comment added John Raya Is that code in PHP?
Mar 3, 2014 at 16:24 history asked Songo CC BY-SA 3.0