gogo-testing

How to run a compiled Go test binary?


I compiled a Go test library by running go test -c ./model. According to Go docs it can be run using go run -exec xprog command, however, I keep getting errors while trying to run my generated model.test binary. What is the full command here?

P.S I know you can use a different flag to compile and run but this is not what I need.


Solution

  • You can run the binary the same as any other. For example, in the shell:

    ./model.test
    

    Test results will be written to the standard output, and the process exit code will be 0 if all tests passed.