@@ -34,6 +34,7 @@ type runOption struct {
34
34
report string
35
35
reportIgnore bool
36
36
level string
37
+ caseItems []string
37
38
}
38
39
39
40
func newDefaultRunOption () * runOption {
@@ -71,6 +72,7 @@ See also https://github.com/LinuxSuRen/api-testing/tree/master/sample`,
71
72
flags .DurationVarP (& opt .duration , "duration" , "" , 0 , "Running duration" )
72
73
flags .DurationVarP (& opt .requestTimeout , "request-timeout" , "" , time .Minute , "Timeout for per request" )
73
74
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" )
74
76
flags .Int64VarP (& opt .thread , "thread" , "" , 1 , "Threads of the execution" )
75
77
flags .Int32VarP (& opt .qps , "qps" , "" , 5 , "QPS" )
76
78
flags .Int32VarP (& opt .burst , "burst" , "" , 5 , "burst" )
@@ -91,6 +93,8 @@ func (o *runOption) preRunE(cmd *cobra.Command, args []string) (err error) {
91
93
default :
92
94
err = fmt .Errorf ("not supported report type: '%s'" , o .report )
93
95
}
96
+
97
+ o .caseItems = args
94
98
return
95
99
}
96
100
@@ -100,7 +104,7 @@ func (o *runOption) runE(cmd *cobra.Command, args []string) (err error) {
100
104
o .context = cmd .Context ()
101
105
o .limiter = limit .NewDefaultRateLimiter (o .qps , o .burst )
102
106
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 ())
104
108
o .limiter .Stop ()
105
109
}()
106
110
@@ -113,6 +117,10 @@ func (o *runOption) runE(cmd *cobra.Command, args []string) (err error) {
113
117
}
114
118
}
115
119
120
+ if o .reportIgnore {
121
+ return
122
+ }
123
+
116
124
// print the report
117
125
var reportErr error
118
126
var results runner.ReportResultSlice
@@ -194,6 +202,10 @@ func (o *runOption) runSuite(suite string, dataContext map[string]interface{}, c
194
202
}
195
203
196
204
for _ , testCase := range testSuite .Items {
205
+ if ! testCase .InScope (o .caseItems ) {
206
+ continue
207
+ }
208
+
197
209
// reuse the API prefix
198
210
if strings .HasPrefix (testCase .Request .API , "/" ) {
199
211
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
204
216
case <- stopSingal :
205
217
return
206
218
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
-
212
219
setRelativeDir (suite , & testCase )
213
220
o .limiter .Accept ()
214
221
0 commit comments