Writing Tests First with Comments
less than a minute
Before you write any new code, say what you are going to do with comments as a four-part unit test.
The Value Proposition
Every developer learns to write code. However, often we start with a set of tests already written for us. It can be harder to learn to write those tests than it was to learn to write code that passes them!
The hard part is that writing a test requires you to clearly state your intention. You need to break the problem down and describe one aspect of your goal. You also need to express that goal in code. Writing tests first with comments allows your to separate these two parts of your thinking. First you will define the goal, then later you will express it in code. This gives several advantages.
- It is much easier to write the tests.
- Each test is easier to make pass.
- The tests are easier to read by other team members.
Please log in
This content is only available to students. Please log in to access it.