Skip to content

Commit

Permalink
Make test results can upload to codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
elct9620 committed Oct 3, 2024
1 parent 035472e commit 8d6831c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ jobs:
with:
mruby-version: ${{ matrix.mruby-version }}
- name: Run tests
run: go test -coverprofile=coverage.txt ./...
run: go test -coverprofile=coverage.txt --godog.format=junit ./...
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
10 changes: 10 additions & 0 deletions godogs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mruby_test
import (
"flag"
"fmt"
"os"
"testing"

"github.com/cucumber/godog"
Expand Down Expand Up @@ -225,6 +226,15 @@ func TestFeatures(t *testing.T) {
o := opts
o.TestingT = t

if o.Format == "junit" {
output, err := os.OpenFile("junit.xml", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
t.Fatal(err)
}
defer output.Close()
o.Output = output
}

suite := godog.TestSuite{
ScenarioInitializer: InitializeScenario,
Options: &o,
Expand Down

0 comments on commit 8d6831c

Please sign in to comment.