Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ jobs:

runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v2
- uses: actions/checkout@v2
- uses: actions/setup-go@v6
with:
go-version: '1.25'
- uses: actions/checkout@v5
- name: Build
run: go build .
- name: Test
Expand Down
8 changes: 8 additions & 0 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ package tc

import (
"fmt"
"math/rand/v2"
"reflect"
"runtime"
"strings"
Expand Down Expand Up @@ -151,6 +152,13 @@ func newSuiteRunner(suite any) *suiteRunner {
runner.tests = append(runner.tests, method)
}
}

// Randomize the test order, so that we never have tests that depend
// on each other passing just because of the order.
rand.Shuffle(len(runner.tests), func(i, j int) {
runner.tests[i], runner.tests[j] = runner.tests[j], runner.tests[i]
})

return runner
}

Expand Down
4 changes: 0 additions & 4 deletions check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ func (s *FixtureHelper) Test1(c *tc.C) {
s.trace("Test1", c)
}

func (s *FixtureHelper) Test2(c *tc.C) {
s.trace("Test2", c)
}

// -----------------------------------------------------------------------
// Helper which checks the state of the test and ensures that it matches
// the given expectations. Depends on c.Errorf() working, so shouldn't
Expand Down
6 changes: 0 additions & 6 deletions run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,25 @@ func (s *RunS) TestFixture(c *C) {
exitCode, output := runHelperSuite("FixtureHelper")
c.Check(exitCode, Equals, 0)
c.Check(output.Status("Test1"), Equals, "PASS")
c.Check(output.Status("Test2"), Equals, "PASS")
}

func (s *RunS) TestPanicOnTest(c *C) {
exitCode, output := runHelperSuite("FixtureHelper", "-helper.panic", "Test1")
c.Check(exitCode, Equals, 2)
c.Check(output.Status("Test1"), Equals, "FAIL")
// stdlib testing stops on first panic
c.Check(output.Status("Test2"), Equals, "")
}

func (s *RunS) TestPanicOnSetUpTest(c *C) {
exitCode, output := runHelperSuite("FixtureHelper", "-helper.panic", "SetUpTest")
c.Check(exitCode, Equals, 2)
c.Check(output.Status("Test1"), Equals, "FAIL")
// stdlib testing stops on first panic
c.Check(output.Status("Test2"), Equals, "")
}

func (s *RunS) TestPanicOnSetUpSuite(c *C) {
exitCode, output := runHelperSuite("FixtureHelper", "-helper.panic", "SetUpSuite")
c.Check(exitCode, Equals, 2)
// If SetUpSuite fails, no tests from the suite are run
c.Check(output.Status("Test1"), Equals, "")
c.Check(output.Status("Test2"), Equals, "")
}

/*
Expand Down
Loading