Go test driven development process
- Start by writing a test for the function (even though it doesn’t exist yet)
- see the test fail with a compilation error because the function doesn’t exist yet
- write the minimum code necessary to make the test compile and fail
- make sure that the test fails for the reason we expected, and check that the failure message is accurate and informative
- write the minimum code necessary to make the test pass
- optionally, tweak and improve the code, preferably without breaking the test
- commit!
This is also known as the red, green, refactor cycle.
References
- John Arundel, For the Love of Go
#programming #golang #for_the_love_of_go #testing #development #red_green_refactor