diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9e2fc62..e935956 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 diff --git a/check.go b/check.go index e9cceae..80ebea9 100644 --- a/check.go +++ b/check.go @@ -34,6 +34,7 @@ package tc import ( "fmt" + "math/rand/v2" "reflect" "runtime" "strings" @@ -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 } diff --git a/check_test.go b/check_test.go index 016a528..316ba3e 100644 --- a/check_test.go +++ b/check_test.go @@ -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 diff --git a/run_test.go b/run_test.go index 011abd2..14a5e4c 100644 --- a/run_test.go +++ b/run_test.go @@ -57,23 +57,18 @@ 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) { @@ -81,7 +76,6 @@ func (s *RunS) TestPanicOnSetUpSuite(c *C) { 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, "") } /*