Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
91 lines (91 sloc) 4.14 KB

TDD With No Tears

I am not all about TDD all the time

I feel like there’s a split

Between people who feel like they “get it” and those who feel like they spin their wheels with TDD most of the time. I want to propose a different way of looking at things.

First, lets review testing

When do you write tests?

The obvious answer is that you should write tests that are helpful and not write tests that are not I do not know why but that seems to be a very difficult idea

Code coverage images

TDD vs BDD

Its about the test expressing clearly what you are testing in business terms - comes down often to how the test is named

How to structure tests

Arrange-Act-Assert

thats very robotic

Given-When-Then

There’s no clear distinction between the first two, I actually like to merge things - when..then another way of looking at it - when…when…when…it

Well that sounds awkward, we can clean that up a bit by not being as literal with the when…then stuff Refactor your tests mercilessly

Stubs vs Mocks

I don’t use mocks often - I feel like their need is a code smell and an indicator of ISP violation

Design not Development

Its great for the situations where you don’t know exactly what to do

We’re going to write down using when…when…when…it format exactly what we want it to do

Example - the timer

  • After a ton of screw turning you finally have a for real user story from your client. Congratulations!
  • As a floor manager I would like an on screen timer so that I can run quick experiments with how long things take to get done
  • Not a ton of design beyond that - maybe a picture of a handheld timer
  • Maybe some sketched out design The thing is, more is not necessary
    • if looking nice is not a prerequisite ie MVP, then don’t worry about making it look nice. This is a legitimate request
    • If the client doesn’t know exactly how it will work, its your job to help them formulate a vision
      • this helps with that!

Live coding

  • [ ] [0/4] Given a new timer with a main and lap slots
    • [ ] it reads nothing in main
    • [ ] it has no laps
    • [ ] When 1s has passed
      • [ ] it reads nothing in main
      • [ ] it has no laps
    • [ ] When timer started
      • [ ] it reads 0 in main
      • [ ] When 10s have passed
        • [ ] main slot reads 10s
        • [ ] there are no laps
        • [ ] When 1s have passed
          • [ ] it reads 11s in main
          • [ ] there are no laps
        • [ ] When lap hit
          • [ ] main slot reads 10s
          • [ ] Lap1 reads 10s
          • [ ] When 1s have passed
            • [ ] main slot reads 11s
            • [ ] Lap1 reads 10s
            • [ ] When lap hit
              • [ ] main slot reads 11s
              • [ ] Lap 1 reads 10s
              • [ ] Lap 2 reads 11s
              • [ ] When 2s have passed
                • [ ] main reads 13s
                • [ ] Lap 1 reads 10s
                • [ ] Lap 2 reads 11s
              • [ ] When reset hit
                • [ ] it reads 0 in main
                • [ ] there are no laps
        • [ ] When reset hit
          • [ ] it reads 0 in main
          • [ ] When 2s have passed
            • [ ] it reads 2s in main
        • [ ] When stopped
          • [ ] it reads 10s in main
          • [ ] When 2s have passed
            • [ ] it reads 10s in main
            • [ ] When started again
              • [ ] it reads 10s in main
              • [ ] When 2s have passed
                • [ ] it reads 12s in main
You can’t perform that action at this time.