Join me at 5 PM ET on my Twitch channel!
Today we'll be working on a code exercise from the JavaScript track of Exercism.io called "D&D Character". In this exercise, we write a class that allows us to generate a character for a role-playing game with random values for different character attributes.
Like all Exercism exercises, this one comes with a prewritten set of tests to guide us. But this time the tests aren't written in the Test-Driven Development style I prefer. We'll look at the tests to see how they aren't enough to fully specify the behavior we want. It's hard to do so when random values are involved! So we'll look at ways we can think about splitting up what is under test and what is not. Along the way we'll uncover an abstraction that will make our tests easier to understand.
My Solution on Exercism.io, including a few final tests for unique attributes and hitpoints.