How it works...
The testing package of the standard library provides support for the code testing needs. The test function needs to fulfill the name pattern, TestXXX. By default, the test tool looks for the file named xxx_test.go. Note that each test function takes the T pointer argument, which provides the useful methods for test control. By the T struct pointer, the status of the test could be set. For instance, the methods Fail and FailNow, cause the test to fail. With the help of the T struct pointer, the test could be skipped by calling Skip, Skipf, or SkipNow.
The interesting method of the T pointer is the method Helper. By calling the method Helper, the current function is marked as the helper function, and if the FailNow (Fatal) is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access