Skip to content

Commit

Permalink
fix: improve test and transaction output when it fails (#2436)
Browse files Browse the repository at this point in the history
* fix: improve test and transaction output when it fails

* add breakline after reason for test failure
  • Loading branch information
mathnogueira committed Apr 25, 2023
1 parent 354b113 commit e2b5354
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
11 changes: 10 additions & 1 deletion cli/formatters/test_run.go
Expand Up @@ -79,7 +79,16 @@ func (f testRun) json(output TestRunOutput) string {

func (f testRun) pretty(output TestRunOutput) string {
if utils.RunStateIsFailed(output.Run.GetState()) {
return f.getColoredText(false, f.formatMessage("Failed to execute test: %s", *output.Run.LastErrorState))
return f.getColoredText(false, fmt.Sprintf("%s\n%s",
f.formatMessage("%s %s (%s)",
FAILED_TEST_ICON,
*output.Test.Name,
output.RunWebURL,
),
f.formatMessage("\tReason: %s\n",
*output.Run.LastErrorState,
),
))
}

if !output.HasResults {
Expand Down
14 changes: 0 additions & 14 deletions cli/formatters/transaction_run.go
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/kubeshop/tracetest/cli/config"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/utils"
"github.com/pterm/pterm"
)

Expand Down Expand Up @@ -79,19 +78,6 @@ func (f transactionRun) json(output TransactionRunOutput) string {
}

func (f transactionRun) pretty(output TransactionRunOutput) string {
if utils.RunStateIsFailed(output.Run.GetState()) {
errorMessage := ""
if len(output.Run.Steps) > 0 {
lastStep := output.Run.Steps[len(output.Run.Steps)-1]
lastError := lastStep.LastErrorState
if lastError != nil {
errorMessage = *lastError
}
}

return f.getColoredText(false, fmt.Sprintf("Failed to execute transaction: %s\n", errorMessage))
}

if !output.HasResults {
return ""
}
Expand Down

0 comments on commit e2b5354

Please sign in to comment.