A sample project for Software Engineers looking to perform unit tests in Go
This example shows a manual test, but can easily be automated via CICD pipelines or runners by DevOps engineers.
As part of the example, I have created an automated test workflow here, which is automatically run when you push to the Main branch.
- Clone the repo to a folder on your PC
- Open Command Prompt
- Navigate to the folder in Step 1, from within Command Prompt
- Run:
go test main.go main_test.go
- You should get an output that says "ok", or an error message showing where the test failed
- To create a Test file, create a new file called *_test.go, where * is the name of the file you're creating tests for.
- Each test method has to start with "Test", and the following word should be capitalized.
- Each test method should be within the same package as the method/function it's testing.