https://github.com/sonalys/gotestfast
A test controller to cache and test prioritize execution.
https://github.com/sonalys/gotestfast
go golang test testing tests
Last synced: about 1 year ago
JSON representation
A test controller to cache and test prioritize execution.
- Host: GitHub
- URL: https://github.com/sonalys/gotestfast
- Owner: sonalys
- License: mit
- Created: 2024-07-11T17:03:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-28T07:31:00.000Z (almost 2 years ago)
- Last Synced: 2025-04-26T15:59:59.794Z (about 1 year ago)
- Topics: go, golang, test, testing, tests
- Language: Go
- Homepage:
- Size: 67.4 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# *GO TEST FAST*
A Golang test execution tool that **prioritizes tests that have failed**. Why run pipelines for several minutes just to reach the test that previously failed?
This tool lists all tests from the given package, prioritizing them in the following order:
1. Tests that have previously failed
2. New tests that were not present in the previous iteration
3. All other tests

## Features
* Colored and human-readable output
* JSON output available for CI
* Caching of previously failing tests for prioritization
* Prioritizes new tests as well
* Coverage support
## Usage
### Go Run
```
go run github.com/sonalys/gotestfast/entrypoints/gotestfast@latest -help
-coverprofile string
If set, writes a coverage profile to the given file
-input string
Path to the Go project folder
-json
Output test results as JSON
-output string
Path to the output file (default "testlog.json")
-pkg string
Comma separated list of packages to test (default "./...")
```
### Go Install
`go install github.com/sonalys/gotestfast/entrypoints/gotestfast@latest`
`gotestfast -input PROJECT_DIR -output CACHE_FILE -pkg ./...`
### CI
For CI, please cache the `CACHE_FILE` for the configured `-output` parameter.
Also, set the `-json` flag for JSON logging.
#### Github Actions
As of the current moment, `actions/cache@v4` `save-always` flag is not working.
I am using a work-around with two separate steps, and `if: always()`
```
- name: Restore test-log cache
uses: actions/cache/restore@v3
with:
path: testlog.json
key: ${{ runner.os }}-testcache
restore-keys: |
${{ runner.os }}-testcache
- name: Test
run: make test
- name: Save test-log cache
if: always()
uses: actions/cache/save@v3
with:
path: testlog.json
key: ${{ runner.os }}-testcache
```
## Contributions
Any issues or ideas are welcome. Just create a new issue.