ChessTDD 35: Acceptance Tests for Knight Movement
Things are really starting to flow with the acceptance tests now. In this episode, not only did I mercifully not uncover any important bugs, but I defined knight movement in acceptance tests in a way that I feel pretty good about. I’m learning as I go about using SpecFlow, which is cool, and as the cherry on the sundae, I actually got episode length back under control with a 17 minute episode.
What I accomplish in this clip:
- Fixed the poor naming I left off with last time.
- Wrote acceptance tests for the knight’s movement.
Here are some lessons to take away:
- Naming is so, so, so important. It may seem like a trivial thing, but leaving a method about chess piece movement where “origin” and “destination” were reversed would, sooner or later, cause someone a serious headache. It would also probably make them hate me when they looked at the history. Make sure your names are good.
- You have to do a fair bit of fumbling when you’re figuring out a new tool/tech/framework on the fly. Stick to your principles and be sensitive to the idea that there’s probably a better way to do a lot of the things that you’re trying to do. Ask people, and read a lot if you can.
- There’s a lot of out of the box stuff that comes when I make a SpecFlow feature, but I just get rid of it. For me, it’s helpful to eliminate everything that I’m not using so as not to be confused about what’s mandatory and what isn’t and also not to be confused later about what functionality I’m even using.
- An interesting tradeoff emerges in my use of SpecFlow. Duplication is, by and large, pretty bad in a code base. But, in the case of visualization, showing the chess board for each individual acceptance test may be helpful in that it makes it crystal clear what’s going on in each test. There are probably various strategies to try optimizing for minimized duplication and maximized visualization simultaneously, but it’s worth bearing in mind that everything in software development is a matter of tradeoffs and it’s best to be deliberate about whatever choice you make.