Skip to content

Commit

Permalink
Continue to run other tests even if any test in middle fails
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <[email protected]>
  • Loading branch information
GLVSKiriti committed Jun 17, 2024
1 parent 74a2a78 commit 44cd4af
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/declarative.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 44cd4af

Please sign in to comment.