@@ -26,6 +26,7 @@ package cmd
26
26
27
27
import (
28
28
"context"
29
+ "errors"
29
30
"fmt"
30
31
"io"
31
32
"log"
@@ -41,6 +42,7 @@ import (
41
42
"github.com/linuxsuren/api-testing/pkg/runner"
42
43
"github.com/linuxsuren/api-testing/pkg/runner/monitor"
43
44
"github.com/linuxsuren/api-testing/pkg/testing"
45
+ "github.com/linuxsuren/api-testing/pkg/util"
44
46
fakeruntime "github.com/linuxsuren/go-fake-runtime"
45
47
"github.com/spf13/cobra"
46
48
"github.com/spf13/pflag"
@@ -320,6 +322,7 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
320
322
return
321
323
}
322
324
325
+ var errs []error
323
326
suiteRunner := runner .GetTestSuiteRunner (testSuite )
324
327
suiteRunner .WithTestReporter (o .reporter )
325
328
suiteRunner .WithSecure (testSuite .Spec .Secure )
@@ -343,15 +346,21 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
343
346
ctxWithTimeout , _ := context .WithTimeout (ctx , o .requestTimeout )
344
347
ctxWithTimeout = context .WithValue (ctxWithTimeout , runner .ContextKey ("" ).ParentDir (), loader .GetContext ())
345
348
346
- if output , err = suiteRunner .RunTestCase (& testCase , dataContext , ctxWithTimeout ); err != nil && ! o .requestIgnoreError {
347
- err = fmt .Errorf ("failed to run '%s', %v" , testCase .Name , err )
348
- return
349
- } else {
350
- err = nil
349
+ output , err = suiteRunner .RunTestCase (& testCase , dataContext , ctxWithTimeout )
350
+ if err = util .ErrorWrap (err , "failed to run '%s', %v" , testCase .Name , err ); err != nil {
351
+ if o .requestIgnoreError {
352
+ errs = append (errs , err )
353
+ } else {
354
+ return
355
+ }
351
356
}
352
357
}
353
358
dataContext [testCase .Name ] = output
354
359
}
360
+
361
+ if len (errs ) > 0 {
362
+ err = errors .Join (errs ... )
363
+ }
355
364
return
356
365
}
357
366
0 commit comments