Skip to content

Commit

Permalink
fix after/before in mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
kandros committed Apr 24, 2019
1 parent df92921 commit 4dd0b73
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,14 @@ The test should pass and no longer taking 4 seconds.

There's still another important property we haven't tested.

`Countdown` should sleep before the first print and then after each one until the last, e.g:
`Countdown` should sleep before each print, e.g:

- `Sleep`
- `Print N`
- `Sleep`
- `Print N-1`
- `Sleep`
- `Print Go!`
- etc

Our latest change only asserts that it has slept 4 times, but those sleeps could occur out of sequence.
Expand Down Expand Up @@ -410,7 +411,7 @@ Our `CountdownOperationsSpy` implements both `io.Writer` and `Sleeper`, recordin
We can now add a sub-test into our test suite.

```go
t.Run("sleep after every print", func(t *testing.T) {
t.Run("sleep before every print", func(t *testing.T) {
spySleepPrinter := &CountdownOperationsSpy{}
Countdown(spySleepPrinter, spySleepPrinter)

Expand Down Expand Up @@ -453,7 +454,7 @@ Go!`
}
})

t.Run("sleep after every print", func(t *testing.T) {
t.Run("sleep before every print", func(t *testing.T) {
spySleepPrinter := &CountdownOperationsSpy{}
Countdown(spySleepPrinter, spySleepPrinter)

Expand Down
2 changes: 1 addition & 1 deletion mocking/v4/countdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Go!`
}
})

t.Run("sleep after every print", func(t *testing.T) {
t.Run("sleep before every print", func(t *testing.T) {
spySleepPrinter := &CountdownOperationsSpy{}
Countdown(spySleepPrinter, spySleepPrinter)

Expand Down
2 changes: 1 addition & 1 deletion mocking/v5/countdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Go!`
}
})

t.Run("sleep after every print", func(t *testing.T) {
t.Run("sleep before every print", func(t *testing.T) {
spySleepPrinter := &CountdownOperationsSpy{}
Countdown(spySleepPrinter, spySleepPrinter)

Expand Down

0 comments on commit 4dd0b73

Please sign in to comment.