@@ -51,7 +51,7 @@ type runOption struct {
51
51
duration time.Duration
52
52
requestTimeout time.Duration
53
53
requestIgnoreError bool
54
- caseFilter string
54
+ caseFilter [] string
55
55
thread int64
56
56
context context.Context
57
57
qps int32
@@ -117,7 +117,7 @@ See also https://github.com/LinuxSuRen/api-testing/tree/master/sample`,
117
117
flags .DurationVarP (& opt .duration , "duration" , "" , 0 , "Running duration" )
118
118
flags .DurationVarP (& opt .requestTimeout , "request-timeout" , "" , time .Minute , "Timeout for per request" )
119
119
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" )
121
121
flags .StringVarP (& opt .report , "report" , "" , "" , "The type of target report. Supported: markdown, md, html, json, discard, std, prometheus, http, grpc" )
122
122
flags .StringVarP (& opt .reportFile , "report-file" , "" , "" , "The file path of the report" )
123
123
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
359
359
}
360
360
runLogger .Info ("run test suite" , "name" , testSuite .Name , "filter" , caseFilter )
361
361
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
+ }
364
376
}
365
377
if ! testCase .InScope (o .caseItems ) {
366
378
continue
0 commit comments