Lesson 22Testing

In order to make sure your Go applications are “job ready,” you should test them to make sure they work correctly. In this lesson, we not only present information on test-driven development, but we introduce behavior-driven development as well. As an added bonus, we walk through an example of a test-driven case.

TEST-DRIVEN DEVELOPMENT

The traditional coding process involves writing code and then running and testing the code to see what happens. If the code fails, you rewrite the program and try it again. If it doesn't fail, you move on to the next program. However, this approach can lead to wasted time because you typically spend a lot of time writing code before testing it, and if the code fails, it takes more time to find and correct the errors. In many respects, it makes more sense to test code as you write it so that you can make corrections as soon as the errors are found.

TESTING LEVELS

There are multiple testing levels that can be used ...

Get Job Ready Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.