No GWT? No code!

As I mentioned in my post on Test Style: AAA or GWT, I’ve deliberately started thinking of everything in terms of GWT (Given-When-Then). So, when I’m beginning to write a new test, instead of writing this:

// Arrange
// Act
// Assert

I write this:

// Given
// When
// Then

Regardless of the style, though, if I can’t think of what should go in each one of those sections, I may have one of two problems:

  • I don’t have enough requirements, or
  • I don’t understand the requirements I have

I’ve gotten into the habit of thinking this way: No GWT, no code!

The reason for that is: if I either don’t have enough requirements or don’t understand the ones I have to a point where I can’t fill out my GWT sections, then I should NOT be writing any code. Whatever code I write is very likely to be thrown away, and unless I have a lot time in my hands to be simply toying with writing code, I should refuse to write any code and go find help to have a clear idea about what I’m supposed to implement.

  1. Leave a comment

Leave a comment