Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jy8752/gotestsum-demo
gotestsumとoctconvを使ったGoのCIにおけるテストレポートの作成デモ
https://github.com/jy8752/gotestsum-demo
ci coverage go golang gotestsum octconv test
Last synced: about 3 hours ago
JSON representation
gotestsumとoctconvを使ったGoのCIにおけるテストレポートの作成デモ
- Host: GitHub
- URL: https://github.com/jy8752/gotestsum-demo
- Owner: JY8752
- Created: 2024-08-28T14:32:14.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-31T13:40:05.000Z (4 months ago)
- Last Synced: 2024-11-12T14:11:44.879Z (2 months ago)
- Topics: ci, coverage, go, golang, gotestsum, octconv, test
- Language: Go
- Homepage:
- Size: 650 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gotestsum-dmeo
![coverage](docs/coverage.svg) ![coverage](docs/ratio.svg) ![coverage](docs/time.svg)
[gotestsum](https://github.com/gotestyourself/gotestsum?tab=readme-ov-file)のデモ。
## install
```
go install gotest.tools/gotestsum@latestgotestsum --version
> gotestsum version dev
```## test
```
% gotestsum --format testdox
gotestsum-demo/calculate:
✓ Add (0.00s)
✓ Add 1+1 (0.00s)
✓ Add 1+2 (0.00s)
✓ Add 1-1 (0.00s)
✓ Add 2+1 (0.00s)gotestsum-demo/hello:
✓ Hello (0.00s)
✓ Hello 2 (0.00s)
✓ Hello hello, go!! (0.00s)
✓ Hello hello, gotestsum!! (0.00s)
✓ Hello hello, world!! (0.00s)
```### alias
```
alias gotest="gotestsum --format testdox"
alias gotestv="gotestsum --format standard-verbose"
``````
% gotest -- -count=1 ./...
gotestsum-demo/calculate:
✓ Add (0.00s)
✓ Add 1+1 (0.00s)
✓ Add 1+2 (0.00s)
✓ Add 1-1 (0.00s)
✓ Add 2+1 (0.00s)gotestsum-demo/hello:
✓ Hello (0.00s)
✓ Hello 2 (0.00s)
✓ Hello hello, go!! (0.00s)
✓ Hello hello, gotestsum!! (0.00s)
✓ Hello hello, world!! (0.00s)
```## output
```
% gotestsum --jsonfile test-output.log
```## notify
Macの場合は[terminal-notifier](https://github.com/julienXX/terminal-notifier)をインストールする
```
brew install terminal-notifier
```通知のexampleコマンドをインストールする。
```
go install gotest.tools/gotestsum/contrib/notify
```以下のテストを実行すると完了後に通知が飛ぶ。
```
% gotestsum --post-run-command notify
```## coverage
[octocov](https://github.com/k1LoW/octocov)を使用してPRのコメントにカバレッジを記載する。カバレッジレポートは以下のようにしてgotestsumを使用しても出力できる。
```
gotestsum --junitfile report.xml --format testdox -- -cover -coverprofile=coverage.out ./...
```## CI
```yaml
- name: Run tests and generate JUnit report, test coverage
run: "${{ env.GOTESTSUM_BIN }}/gotestsum --junitfile report.xml --format testdox -- -cover -coverprofile=coverage.out ./..."- name: Upload test report and coverage
uses: actions/upload-artifact@v4
with:
name: junit-test-report-and-coverage
path: |
report.xml
coverage.out- name: Test Report Summary
if: success() || failure()
uses: dorny/test-reporter@v1
with:
name: Tests
path: "*.xml"
reporter: java-junit- uses: k1LoW/octocov-action@v1
```
## Sample
### Coverage
### Report