@@ -51,7 +51,7 @@ type runOption struct {
5151 duration time.Duration
5252 requestTimeout time.Duration
5353 requestIgnoreError bool
54- caseFilter string
54+ caseFilter [] string
5555 thread int64
5656 context context.Context
5757 qps int32
@@ -117,7 +117,7 @@ See also https://github.com/LinuxSuRen/api-testing/tree/master/sample`,
117117 flags .DurationVarP (& opt .duration , "duration" , "" , 0 , "Running duration" )
118118 flags .DurationVarP (& opt .requestTimeout , "request-timeout" , "" , time .Minute , "Timeout for per request" )
119119 flags .BoolVarP (& opt .requestIgnoreError , "request-ignore-error" , "" , false , "Indicate if ignore the request error" )
120- flags .StringVarP (& opt .caseFilter , "case-filter" , "" , "" , "The filter of the test case" )
120+ flags .StringArrayVarP (& opt .caseFilter , "case-filter" , "" , nil , "The filter of the test case" )
121121 flags .StringVarP (& opt .report , "report" , "" , "" , "The type of target report. Supported: markdown, md, html, json, discard, std, prometheus, http, grpc" )
122122 flags .StringVarP (& opt .reportFile , "report-file" , "" , "" , "The file path of the report" )
123123 flags .BoolVarP (& opt .reportIgnore , "report-ignore" , "" , false , "Indicate if ignore the report output" )
@@ -359,8 +359,20 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
359359 }
360360 runLogger .Info ("run test suite" , "name" , testSuite .Name , "filter" , caseFilter )
361361 for _ , testCase := range testSuite .Items {
362- if caseFilterObj != nil && ! strings .Contains (testCase .Name , caseFilterObj .(string )) {
363- continue
362+ if caseFilterObj != nil {
363+ if filter , ok := caseFilterObj .([]string ); ok && len (filter ) > 0 {
364+ match := false
365+ for _ , ff := range filter {
366+ if strings .Contains (testCase .Name , ff ) {
367+ match = true
368+ break
369+ }
370+ }
371+
372+ if ! match {
373+ continue
374+ }
375+ }
364376 }
365377 if ! testCase .InScope (o .caseItems ) {
366378 continue
0 commit comments