mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Added `parallelsuite` package to provide an alternative to testify's suite. **For reviewer: Use "Hide Whitespace" to make the diff smaller.** ## Why? 1. **Parallel by default**: all test methods and subtests run in parallel automatically 2. **IDE support**: GoLand run gutters, navigation, and test discovery work on Test* methods 4. **Misuse detection**: guard catches mixing assertions with Run(), both directions, at runtime 5. **Type-safe subtests**: `s.Run` callbacks receive the concrete suite type, so suite helpers are available 6. **No shared state**: each test method and subtest gets its own fresh copy ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [x] added new unit test(s) - [ ] added new functional test(s)
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package parallelsuite
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
testifysuite "github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
// testifyBase wraps testify's suite.Suite so that Suite's *require.Assertions
|
|
// shadows testify's *assert.Assertions in Go's embedding resolution.
|
|
// It disables all testify suite methods with panicking stubs.
|
|
type testifyBase struct {
|
|
testifysuite.Suite
|
|
}
|
|
|
|
// Deprecated: SetT is managed internally by [Run]. Do not call directly.
|
|
func (b *testifyBase) SetT(_ *testing.T) {
|
|
panic("parallelsuite: do not call SetT directly; it is managed by parallelsuite.Run")
|
|
}
|
|
|
|
// Deprecated: SetS is managed internally by [Run]. Do not call directly.
|
|
func (b *testifyBase) SetS(_ testifysuite.TestingSuite) {
|
|
panic("parallelsuite: do not call SetS directly; it is managed by parallelsuite.Run")
|
|
}
|
|
|
|
// Deprecated: Assert returns non-fatal assertions which are not supported.
|
|
// Use s.NoError, s.Equal, etc. directly (require semantics).
|
|
func (b *testifyBase) Assert() *assert.Assertions {
|
|
panic("parallelsuite: do not use Assert(); use s.NoError, s.Equal, etc. directly")
|
|
}
|
|
|
|
// Deprecated: Require bypasses the guard mechanism. Use s.NoError, s.Equal, etc. directly.
|
|
func (b *testifyBase) Require() *require.Assertions {
|
|
panic("parallelsuite: do not use Require(); use s.NoError, s.Equal, etc. directly")
|
|
}
|