Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: convenient assert syntax #49

Open
xhd2015 opened this issue Apr 11, 2024 · 2 comments
Open

Feature: convenient assert syntax #49

xhd2015 opened this issue Apr 11, 2024 · 2 comments
Labels

Comments

@xhd2015
Copy link
Owner

xhd2015 commented Apr 11, 2024

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.

@WAY29
Copy link

WAY29 commented Apr 20, 2024

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

@xhd2015
Copy link
Owner Author

xhd2015 commented Apr 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants