December 2021
Intermediate to advanced
510 pages
11h 20m
English
The goci tool executes tasks on a Go project. To write tests for it, we need to create a few small Go programs. Let’s start with two test cases, one for a successful build and one for a failed build so we can test the error handling. Create a directory testdata under your project directory to hold the files required for the testing. When building goci any files under this directory are ignored. In addition, create two subdirectories under testdata to hold the code for each case: tool and toolErr:
| | $ mkdir -p $HOME/pragprog.com/rggo/processes/goci/testdata/{tool,toolErr} |
Switch to the newly created testdata/tool directory and initialize a new dummy module for this project:
| | $ cd $HOME/pragprog.com/rggo/processes/goci/testdata/tool ... |
Read now
Unlock full access