From 44cd4af78c584c9cec867cc70d2fd5d86643a68f Mon Sep 17 00:00:00 2001 From: GLVS Kiriti Date: Mon, 17 Jun 2024 15:51:54 +0530 Subject: [PATCH] Continue to run other tests even if any test in middle fails Signed-off-by: GLVS Kiriti --- cmd/declarative.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/declarative.go b/cmd/declarative.go index 2d402978..c1a5306d 100644 --- a/cmd/declarative.go +++ b/cmd/declarative.go @@ -39,13 +39,22 @@ func NewDeclarative() *cobra.Command { return err } + var failedTests []error // stores the errors of failed tests + // Execute each test mentioned in yaml file for _, eachTest := range tests.Tests { err := runTestSteps(eachTest) if err != nil { - return err + // Collect the errors if any test fails + failedTests = append(failedTests, fmt.Errorf("test %v failed with err: %v", eachTest.Rule, err)) } } + + // Print all errors + if len(failedTests) > 0 { + return fmt.Errorf("some tests failed %v", failedTests) + } + return nil }