@@ -34,6 +34,7 @@ type runOption struct {
3434 report string
3535 reportIgnore bool
3636 level string
37+ caseItems []string
3738}
3839
3940func newDefaultRunOption () * runOption {
@@ -71,6 +72,7 @@ See also https://github.com/LinuxSuRen/api-testing/tree/master/sample`,
7172 flags .DurationVarP (& opt .duration , "duration" , "" , 0 , "Running duration" )
7273 flags .DurationVarP (& opt .requestTimeout , "request-timeout" , "" , time .Minute , "Timeout for per request" )
7374 flags .BoolVarP (& opt .requestIgnoreError , "request-ignore-error" , "" , false , "Indicate if ignore the request error" )
75+ flags .BoolVarP (& opt .reportIgnore , "report-ignore" , "" , false , "Indicate if ignore the report output" )
7476 flags .Int64VarP (& opt .thread , "thread" , "" , 1 , "Threads of the execution" )
7577 flags .Int32VarP (& opt .qps , "qps" , "" , 5 , "QPS" )
7678 flags .Int32VarP (& opt .burst , "burst" , "" , 5 , "burst" )
@@ -91,6 +93,8 @@ func (o *runOption) preRunE(cmd *cobra.Command, args []string) (err error) {
9193 default :
9294 err = fmt .Errorf ("not supported report type: '%s'" , o .report )
9395 }
96+
97+ o .caseItems = args
9498 return
9599}
96100
@@ -100,7 +104,7 @@ func (o *runOption) runE(cmd *cobra.Command, args []string) (err error) {
100104 o .context = cmd .Context ()
101105 o .limiter = limit .NewDefaultRateLimiter (o .qps , o .burst )
102106 defer func () {
103- cmd .Printf ("consume: %s\n " , time .Now (). Sub (o .startTime ).String ())
107+ cmd .Printf ("consume: %s\n " , time .Since (o .startTime ).String ())
104108 o .limiter .Stop ()
105109 }()
106110
@@ -113,6 +117,10 @@ func (o *runOption) runE(cmd *cobra.Command, args []string) (err error) {
113117 }
114118 }
115119
120+ if o .reportIgnore {
121+ return
122+ }
123+
116124 // print the report
117125 var reportErr error
118126 var results runner.ReportResultSlice
@@ -194,6 +202,10 @@ func (o *runOption) runSuite(suite string, dataContext map[string]interface{}, c
194202 }
195203
196204 for _ , testCase := range testSuite .Items {
205+ if ! testCase .InScope (o .caseItems ) {
206+ continue
207+ }
208+
197209 // reuse the API prefix
198210 if strings .HasPrefix (testCase .Request .API , "/" ) {
199211 testCase .Request .API = fmt .Sprintf ("%s%s" , testSuite .API , testCase .Request .API )
@@ -204,11 +216,6 @@ func (o *runOption) runSuite(suite string, dataContext map[string]interface{}, c
204216 case <- stopSingal :
205217 return
206218 default :
207- // reuse the API prefix
208- if strings .HasPrefix (testCase .Request .API , "/" ) {
209- testCase .Request .API = fmt .Sprintf ("%s%s" , testSuite .API , testCase .Request .API )
210- }
211-
212219 setRelativeDir (suite , & testCase )
213220 o .limiter .Accept ()
214221
0 commit comments