smartystreets / goconvey

Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.
http://smartystreets.github.io/goconvey/
Other
8.23k stars 554 forks source link

convey.So bug report: errors.New() compares with nil return wrong result #666

Open LugeKit opened 2 years ago

LugeKit commented 2 years ago

Version: v1.7.2 ApplyFunc use github.com/agiledragon/gomonkey/v2 v2.1.0

Code:

func Test(t *testing.T) {
    Convey("Test", t, func() {
        defer ApplyFunc(json.Marshal, func(v interface{}) ([]byte, error) {
            return nil, errors.New("test shouldNotEqual")
        }).Reset()

        _, err := json.Marshal("")
        So(err, ShouldNotEqual, nil)
    })
}

Result:

Failures:
  Line 97:
  Expected     'test shouldNotEqual'
  to NOT equal '<nil>'
  (but it did)!

1 total assertion

--- FAIL: Test (0.00s)

FAIL