Closed eodnozerkin-ozon closed 2 years ago
There is a suggestion:
We have opportunity to filter methods from the structure with method's name. So, theoretically we can search methods with specific prefix (TableTest
or ParametrizedTest
or DataDrivenTest
or other) and look for the fields of the structure with name of method without prefix.
For exmaple:
type SomeSuite struct {
suite.Suite
MyTest []*SomeType
}
func (s *SomeSuite) TableTestMyTest(t provider.T, param *SomeType) {
// ....
}
We have suite structure SomeSuite and it has TableTestMyTest
test method.
So we can find field with name MyTest in SomeSuite struct and loop it in the RunTests method for MyTest array length
Something like
trimmedMethodName := strings.TrimPrefix(method.Name(), "TableTest")
params := reflect.ValueOf(suite).Elem().FieldByName(trimmedMethodName).MapRange()
for iter.Next() {
// some magic validation for the safety
// setting ParentSuite and Suite fields
method.Func.Call(suite, t, param)
}
Describe the solution you'd like Parametrization semantics without loops
Additional context Add test generation based on test cases. Examples: