Table of Contents – Adding Tests for a Function
In this chapter, the overall idea was to take an existing function, such as you might have sitting around right now, and write tests for it. There are likely functions and tools that we already have that don’t have a tests, and with the help of this chapter can start thinking through the logic of writing tests. This chapter makes perfect sense, and for me, lines up well. That’s what’s I’ve been doing — writing tests for an existing function I’ve authored. That said, I can’t wait to start my next tool from the beginning and experiment with TDD, and getting those tests in place before I start writing my solutions to pass the tests.
In regard to writing tests, as that’s what we’re after here, I highlighted the below two sentences. It basically says this: “It’s okay if you don’t incorporate all the test possibilities right away. You can come back and add more later.” I really needed to hear this.
As we moved through the chapter, we walked and talked though various things we would test against Warren Frame‘s Invoke-Parallel function. I won’t spend anytime going over the tests, or the function, but I really did appreciate the walk though experimentation and out loud thinking of this chapter. I picked up a few hints, and I’ll share one before wrapping up. It’s okay to include more than a single Should comparison in the same It block, providing they make sense together. If including multiple assertions makes sense to your It block’s purpose, then do so freely. Good to know, and great chapter.