December 2021
Intermediate to advanced
510 pages
11h 20m
English
When you wrote the integration tests for the list functionality, you used the testdata directory and a set of files to support your test cases. This procedure works well when the directory structure doesn’t change. But if you want to test file deletion, this may not be the best option because the files will be deleted after the first test, and you would have to keep creating them for every test run.
Instead, automate the creation and cleanup of the test directory and files for every test. In Go, you accomplish this by writing a test helper function and calling this function from within each test. A test helper function is similar to other functions, but you explicitly mark it as a test helper by calling ...
Read now
Unlock full access