- The Analogy
- Testing
- Testing Do's
- Testing Don'ts
- Summary
- a.k.a. CYA testing
- Testing the framework, core, standard libraries?
- Testing across boundaries?
- Beware of binding logic to the ORM methods
- Use abstractions wisely
- Do remember separation of concerns, "It's Not My Business")
- Test the public interface
- Test behavior
- Stub and mock to isolate SUT
- Do watch out for smells
- Use factories
- Test edge cases, integration points
- Use memory, rather than persistent models
- Remember the Law of Demeter
- Cross Boundaries
- Don't test the framework (e.g. associations, simple scopes)
- Don't get emotional about testing
- Don't test privates
- Mock everything (it's not the hammer)
- Test edge cases with integration tests
Background:
It's tax season and I had to overnight my all my W-2s and whatnot to my tax guy in California and he had to overnight all the finished tax forms back to me, to sign, and send to that wonderful agency known as the Internal Revenue Service.
So lets discuss the curious path of this request.
- Sender address follows standard format
- Return to sender
- Receiver address follows standard format
- Can't find address
- Return to sender
- Stamp? Stamp previously used on other envelope?
- Letter too heavy?
- USPS already picked up mail?
- Mail damaged?
- Am I using USPS, FedEx, UPS?
- Do I want tracking?
- Do I want insurance?
- Do I require a signature?
- What are the contents? (Are the allowed?)
- Goes to Chicago, IL sorting center →
- Leave's distribution center →
- Arrive's in receivers distribution center →
- Moved to Whittier, CA post office sorting center →
- Out for delivery
- Address found? If not, return to send
- Is content's correct, according to the manifest
- Are the content's filled out correctly?
- Does Mike have all the information he needs?
- Did I include personal check? If not, light contents on fire.
- Extracts facts from my documents
- Translates facts into a story that maximizes my returns
- Loads values into government forms
- Prints out new documents
- Stuffs into envelope for pickup from office
- Goes to Whitter, CA sorting center →
- Leave's distribution center →
- Arrive's in receivers distribution center →
- Moved to Chicago, IL post office sorting center →
- Out for delivery
- Address found? If not, return to sender
- Service Unavailable (503)
- Is this Mike the CPA's correct address?
- Do my taxes look like they are filled out correctly?
- What's my address?
- How do you plan to deliver the mail, which route?
- Can you please mail this without a stamp?
- Can you just mail this UPS box? You are headed that way anyway
- The envelope from Mike, so.... whats in here?
- Mind if I wait in your sorting center until the letter from Mike comes?
- Did Ted include a check?
- Did this include Ted's W-2s?
- How much lying did he do?
- Is this Ted's real address?
- Did you give Mike everything he wants?
- Did you provide Ted with self-address stamped envelopes to the IRS?
- Separation of concerns
- "It's Not My Business"
- Show models, collaborators, components
- Interaction
- Business logic
- Integrate
- Not too much
- Not to little
- Test points of integration
- Test points of integration in isolated business units