From 62f54162e496403e683b8fb7cf79b1ecbdbfa4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=81=AA?= Date: Tue, 18 Jan 2022 21:33:41 +0800 Subject: [PATCH 1/3] fix: no error is logged when the assertion fails --- internal/boomer/stats.go | 1 + response.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/internal/boomer/stats.go b/internal/boomer/stats.go index 53b4f707..57af9654 100644 --- a/internal/boomer/stats.go +++ b/internal/boomer/stats.go @@ -66,6 +66,7 @@ func (s *requestStats) logTransaction(name string, success bool, responseTime in s.transactionPassed++ } else { s.transactionFailed++ + s.get(name, "transaction").logError("") } s.get(name, "transaction").log(responseTime, contentLength) } diff --git a/response.go b/response.go index e57608fe..258393cd 100644 --- a/response.go +++ b/response.go @@ -2,6 +2,8 @@ package hrp import ( "encoding/json" + "fmt" + "github.com/pkg/errors" "io/ioutil" "net/http" "strings" @@ -131,6 +133,12 @@ func (v *responseObject) Validate(validators []Validator, variablesMapping map[s Msgf("validate %s", checkItem) if !result { v.t.Fail() + return errors.New(fmt.Sprintf( + "do assertion failed, assertMethod: %v, expectValue: %v, checkValue: %v", + assertMethod, + expectValue, + checkValue, + )) } } return nil From 96a731b5920a7eb465d2f5812be54c325e30f2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=81=AA?= Date: Tue, 18 Jan 2022 21:37:03 +0800 Subject: [PATCH 2/3] fix: no error is logged when the assertion fails --- response.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/response.go b/response.go index 258393cd..a365c596 100644 --- a/response.go +++ b/response.go @@ -3,12 +3,13 @@ package hrp import ( "encoding/json" "fmt" - "github.com/pkg/errors" "io/ioutil" "net/http" "strings" "testing" + "github.com/pkg/errors" + "github.com/jmespath/go-jmespath" "github.com/rs/zerolog/log" From ec44dd41b0ed2e4300e668245b276a9b24fc89b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=81=AA?= Date: Tue, 18 Jan 2022 22:10:50 +0800 Subject: [PATCH 3/3] fix: no error is logged when the assertion fails --- response.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/response.go b/response.go index a365c596..77abb4dc 100644 --- a/response.go +++ b/response.go @@ -8,9 +8,8 @@ import ( "strings" "testing" - "github.com/pkg/errors" - "github.com/jmespath/go-jmespath" + "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/httprunner/hrp/internal/builtin"