@@ -162,16 +162,8 @@ func findParentTestCases(testcase *testing.TestCase, suite *testing.TestSuite) (
162162 }
163163 }
164164
165- for _ , sub := range reg .FindStringSubmatch (testcase .Request .API ) {
166- // remove {{ and }}
167- if left , leftErr := regexp .Compile (`.*\{\{` ); leftErr == nil {
168- api := left .ReplaceAllString (sub , "" )
169-
170- expectName = targetReg .FindString (api )
171- expectName = strings .TrimPrefix (expectName , "." )
172- expectNames .Push (expectName )
173- }
174- }
165+ findExpectNames (testcase .Request .API , expectNames )
166+ findExpectNames (testcase .Request .Body , expectNames )
175167
176168 fmt .Println ("expect test case names" , expectNames .GetAll ())
177169 for _ , item := range suite .Items {
@@ -183,6 +175,22 @@ func findParentTestCases(testcase *testing.TestCase, suite *testing.TestSuite) (
183175 return
184176}
185177
178+ func findExpectNames (target string , expectNames * UniqueSlice [string ]) {
179+ reg , _ := regexp .Compile (`(.*?\{\{.*\.\w*.*?\}\})` )
180+ targetReg , _ := regexp .Compile (`\.\w*` )
181+
182+ for _ , sub := range reg .FindStringSubmatch (target ) {
183+ // remove {{ and }}
184+ if left , leftErr := regexp .Compile (`.*\{\{` ); leftErr == nil {
185+ body := left .ReplaceAllString (sub , "" )
186+
187+ expectName := targetReg .FindString (body )
188+ expectName = strings .TrimPrefix (expectName , "." )
189+ expectNames .Push (expectName )
190+ }
191+ }
192+ }
193+
186194// UniqueSlice represents an unique slice
187195type UniqueSlice [T comparable ] struct {
188196 data []T
0 commit comments