Atlas › Test
wrong_method_signature
Exact test identity: go.temporal.io/server/common/testing/parallelsuite/TestRun_RejectsSuite/wrong_method_signature
- Package
go.temporal.io/server/common/testing/parallelsuite
- Suite / test hierarchy
TestRun_RejectsSuite/wrong_method_signature
- Test
wrong_method_signature
- Introduced at
- suite.go ×1 Frontier kind: Joint frontier
- Covered ranges
- 12
- Covered lines
- 43
- Covered files
- 1
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/testing/parallelsuite/suite.go 43 covered LOC · 12 ranges
Open complete file
177
//
178
// The suite must embed [Suite] and have no other fields.
179
>
func Run[T testingSuite](t *testing.T, s T, args ...any) {
suite.go
180
>
run(t, s, true, args...)
181
>
}
182
183
// RunLegacySequential behaves like [Run] but does not mark test methods as parallel.
189
}
190
191
>
func run[T testingSuite](t *testing.T, s T, methodsParallel bool, args ...any) {
suite.go
192
>
t.Helper()
193
>
194
>
typ := reflect.TypeFor[T]()
195
>
if typ.Kind() != reflect.Pointer || typ.Elem().Kind() != reflect.Struct {
196
panic(fmt.Sprintf("parallelsuite.Run: suite must be a pointer to a struct, got %v", typ))
197
}
199
>
200
>
validateSuiteStruct(structType)
201
>
202
>
methods := discoverTestMethods(typ, structType, args)
203
>
if len(methods) == 0 {
204
panic(fmt.Sprintf("parallelsuite.Run: suite %s has no Test* methods", structType.Name()))
205
}
228
var inheritedMethods map[string]bool
229
231
>
type ds struct{ Suite[*ds] }
232
>
ptrType := reflect.TypeFor[*ds]()
233
>
inheritedMethods = make(map[string]bool, ptrType.NumMethod())
234
>
for method := range ptrType.Methods() {
235
>
inheritedMethods[method.Name] = true
236
>
}
237
}
238
239
>
func validateSuiteStruct(structType reflect.Type) {
suite.go
240
>
if !strings.HasSuffix(structType.Name(), "Suite") {
241
panic(fmt.Sprintf("parallelsuite.Run: struct name %q must end with \"Suite\"", structType.Name()))
242
}
243
244
>
if structType.NumField() != 1 {
suite.go
245
panic(fmt.Sprintf(
246
"parallelsuite.Run: suite %s must have no fields besides the embedded parallelsuite.Suite; "+
249
))
250
}
252
>
if !f.Anonymous {
253
panic(fmt.Sprintf(
254
"parallelsuite.Run: suite %s must embed parallelsuite.Suite, found named field %q",
285
}
286
287
>
func discoverTestMethods(ptrType, structType reflect.Type, args []any) []reflect.Method {
suite.go
288
>
expectedNumIn := 1 + len(args)
289
>
290
>
for method := range ptrType.Methods() {
291
>
name := method.Name
292
>
if !strings.HasPrefix(name, "Test") && !inheritedMethods[name] {
293
panic(fmt.Sprintf(
294
"parallelsuite.Run: suite %s has exported method %s that does not start with Test; "+
299
}
300
301
>
var methods []reflect.Method
suite.go
302
>
for method := range ptrType.Methods() {
303
>
if !strings.HasPrefix(method.Name, "Test") {
304
>
continue
305
}
306
308
>
if mt.NumOut() != 0 {
309
panic(fmt.Sprintf(
310
"parallelsuite.Run: method %s.%s must not have return values, got %v",
312
))
313
}
314
>
if mt.NumIn() != expectedNumIn {
suite.go
316
>
"parallelsuite.Run: method %s.%s has wrong number of parameters: expected %d, got %d (%v)",
317
>
structType.Name(), method.Name, expectedNumIn, mt.NumIn(), mt,
318
>
))
319
}
320