Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xtruder/go-testparrot
Golang tool to record and replay expected test values, just like a parrot :parrot: :bird:
https://github.com/xtruder/go-testparrot
automation golang record recorder replay test-automation testing tool
Last synced: 6 days ago
JSON representation
Golang tool to record and replay expected test values, just like a parrot :parrot: :bird:
- Host: GitHub
- URL: https://github.com/xtruder/go-testparrot
- Owner: xtruder
- License: mpl-2.0
- Created: 2021-01-09T21:31:17.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-05-19T15:56:59.000Z (over 1 year ago)
- Last Synced: 2024-06-20T22:34:04.548Z (5 months ago)
- Topics: automation, golang, record, recorder, replay, test-automation, testing, tool
- Language: Go
- Homepage:
- Size: 65.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
![tests](https://github.com/xtruder/go-testparrot/workflows/test/badge.svg)
# go-testparrot :parrot:
go-testparrot records and replies expected test values, so you don't have
to hardcode complex test values.## About
Are you **tired of hard coding** values in tests?
Do you **copy paste failed test values** like as monkey?**What if there would be a record button to record test values and reply them
later, just like a parrot!**### Features
- Simple interface for record and reply values based on sequential or key value.
- Generation of recorded values in readable go code.## Quick start
### Create a package with some tests:
```go
package exampleimport (
"testing""github.com/xtruder/go-testparrot"
)func doSomething() string {
return "value"
}func TestSomething(t* testing.T) {
value := doSomething()// When running in recording mode return value will equal
// passed value and file with recordings will be generated.
// When running without recording, values from recording file
// will be replied.
expected := testparrot.RecordNext(t, value)if value != expected {
t.Errorf("doSomething() = %v; want %v", value, expected)
}
}func TestMain(m *testing.M) {
testparrot.Run(m)
}
```You must provide `TestMain` method that will run `testparrot.Run` of if you need additional steps after/before running tests, you can also use `testparrot.BeforeTests` and `testparrot.AfterTests` helper methods.
### Record values
To record values run tests with recording enabled:
```bash
go test -testparrot.record
```This will record values and save them into `_recording_test.go` file in same directory as tests.
You can also use `go:generate` by placing comment like:
```go
//go:generate go test ./ -testparrot.record
```in package under test and running `go generate `
### Run tests
Run tests like you woul ussually run them, but with recording disabled:
```bash
go test
```## Developing go-testparrot
See
[CONTRIBUTING.md](https://github.com/xtruder/go-testparrot/blob/master/.github/CONTRIBUTING.md)
for best practices and instructions on setting up your development environment
to work on Packer.