Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattwelke/go-mocking-tutorial
https://github.com/mattwelke/go-mocking-tutorial
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mattwelke/go-mocking-tutorial
- Owner: mattwelke
- Created: 2024-04-04T07:49:55.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-04T16:04:43.000Z (9 months ago)
- Last Synced: 2024-10-14T02:24:12.884Z (3 months ago)
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-mocking-tutorial
This is a tutorial/workshop on:
* How state verification and behavior verification work when testing code.
* Why mocks help with behavior verification.
* Why mocking libraries ([testify](https://github.com/stretchr/testify) used as an example) help with mocking while writing tests for Go code.My inspiration for writing this tutorial comes from my experience first getting started with automated software testing early in my career, then getting familiar with how to do basic forms of it in Go (e.g. generating test tables for pure functions) while encountering insights throughout my career from industry leaders such as Martin Fowler (e.g. his [Mocks Aren't Stubs](https://martinfowler.com/articles/mocksArentStubs.html) article), and then learning more advanced forms of testing in Go.
## Getting started
Follow the tutorial by reading each README file in each directory in alphabetical order. Each README file explains testing concepts and describes the Go code contents of the directory.
If your system meets the following requirements, you can run the demonstration code yourself:
* Go 1.22+, or
* VS Code (with Go downloaded automatically by VS Code)To run the tests, run `go test` in the subdirectory or click "run test" etc in VS Code next to the test you want to run.