Chapter 7: "There’s no code for you to write in this chapter" (page 168)

When starting Chapter 7 (All About Testing), there is an aside that says:

There’s no code for you to write in this chapter — Tunez comes with a full set of tests pre-prepared, but they’re all skipped and commented out…

Knowing this, I proceed to the first test:

test "when there is no data, nothing is returned" do

However, there is no matching code block in my Tunez repo with this text in it.

So I do need to write some code in this chapter?

I had assumed the code would be commented out, but in the repo.

Thanks

Right, I see how that’s confusing! Some of the tests in the book, such as that initial one, are meant as demonstrations of tests - you can write them, and they will pass, but we haven’t included them in the app. This chapter is more illustrative, meant to show possibilities that you can apply when you need them.

As we state later on (perhaps way too late) - realistically, we wouldn’t write all of the tests that we demonstrate, because Tunez isn’t complex enough to need them. The generator we write is “real”, as are the interface tests and some of the policy tests, but in reality most of our “real” tests cover action calls, the search UI, and policies, and aren’t super interesting! Once you’ve seen one, you’ve got an idea of how the rest work.

I’ll have a think how this can be improved for the next beta. I think the approach in the Tunez app is correct (don’t fill it full of tests for the sake of tests) but the description in the book needs to be clearer…

1 Like