xgo icon indicating copy to clipboard operation
xgo copied to clipboard

Feature: convenient assert syntax

Open xhd2015 opened this issue 2 years ago • 2 comments

When writing asserts, could we just naturally do the actual check without repeating any name?

Current situation:

if result!="1234"{
    t.Fatalf("expect result to be %s, actual: %s", "123", result)
}

If we can just write:

assert.Assert(result=="1234")

And xgo prints the variable name and actual value in a breaking down style upon failure:

xxx_test.go:12    result=="1234"
                    ^
                    "123"

Besides, I think maybe we need to let user write AST plugins.

xhd2015 avatar Apr 11 '24 02:04 xhd2015

Look like a good idea. maybe xgo can be a all in one test suite?

WAY29 avatar Apr 20 '24 15:04 WAY29

Look like a good idea. maybe xgo can be a all in one test suite?

@WAY29 Thanks, groovy supports this assert feature, that's where the idea comes from. As for all in one, it could be completely possible if we can provide all features out of box that are required for writing tests.

xhd2015 avatar Apr 20 '24 23:04 xhd2015