Relationship Between the Test Name and Test in TDD
The relationship between the test name and the implementation of the test must be consistent. We want to avoid code like this:
it 'Dog should wag the tail when it sees the owner' do owner = Person.new dog = Dog.new result = dog.see(owner) assert_equal 'bark', result end
This example seems obvious but developers make this very common mistake. We can fix this code as follows:
it 'Dog should wag the tail when it sees the owner' do owner = Person.new dog = Dog.new result = dog.see(owner) assert_equal 'wagging my tail', result end
The mistake is often caused by lack of knowledge about the domain because the developer is unfamiliar with the domain. So, instead of blindly adding new tests, during the refactoring step - we must review the existing tests and make decisions about deleting or updating the tests to reflect our growing knowledge about the domain. By doing so, we as developers make the transition from
Me Milk to
Please give me some milk to drink.
A test must be syntactically and semantically correct. Ruby interpreter enforces the syntactic correctness of a test. It is the developer's responsibility to enforce the semantic correctness of a test.
I discuss this in depth in my upcoming TDD in Ruby book scheduled for release in March 2017 by Apress. Subscribe to my newsletter if you want to be notified about the discount coupon codes for the upcoming book.
Software Compatibility Best Practices
I spoke to some of the most talented and experienced software developers. I have created a guide that is filled with valuable insights and actionable ideas to boost developer productivity.
You will gain a better understanding of what's working well for other developers and how they address the software compatibility problems.