@@ -26,6 +26,7 @@ package cmd
2626
2727import (
2828 "context"
29+ "errors"
2930 "fmt"
3031 "io"
3132 "log"
@@ -41,6 +42,7 @@ import (
4142 "github.com/linuxsuren/api-testing/pkg/runner"
4243 "github.com/linuxsuren/api-testing/pkg/runner/monitor"
4344 "github.com/linuxsuren/api-testing/pkg/testing"
45+ "github.com/linuxsuren/api-testing/pkg/util"
4446 fakeruntime "github.com/linuxsuren/go-fake-runtime"
4547 "github.com/spf13/cobra"
4648 "github.com/spf13/pflag"
@@ -320,6 +322,7 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
320322 return
321323 }
322324
325+ var errs []error
323326 suiteRunner := runner .GetTestSuiteRunner (testSuite )
324327 suiteRunner .WithTestReporter (o .reporter )
325328 suiteRunner .WithSecure (testSuite .Spec .Secure )
@@ -343,15 +346,21 @@ func (o *runOption) runSuite(loader testing.Loader, dataContext map[string]inter
343346 ctxWithTimeout , _ := context .WithTimeout (ctx , o .requestTimeout )
344347 ctxWithTimeout = context .WithValue (ctxWithTimeout , runner .ContextKey ("" ).ParentDir (), loader .GetContext ())
345348
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+ }
351356 }
352357 }
353358 dataContext [testCase .Name ] = output
354359 }
360+
361+ if len (errs ) > 0 {
362+ err = errors .Join (errs ... )
363+ }
355364 return
356365}
357366
0 commit comments