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

Wrong using defer in example #77

Closed
KolesnikDmitriy opened this issue Sep 26, 2023 · 4 comments
Closed

Wrong using defer in example #77

KolesnikDmitriy opened this issue Sep 26, 2023 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@KolesnikDmitriy
Copy link
Collaborator

Describe the bug
Incorrect example with defer. Require my stops test execution when a test result fails, and defer stack will not fill.

To Reproduce
Steps to reproduce the behavior:
look through example:
https://github.com/ozontech/allure-go/blob/master/examples/suite_demo/setup_test.go#L92

Expected behavior
defer should executed right after context declaration

@KolesnikDmitriy KolesnikDmitriy added the documentation Improvements or additions to documentation label Sep 26, 2023
@KolesnikDmitriy KolesnikDmitriy self-assigned this Sep 26, 2023
@siller174
Copy link
Collaborator

siller174 commented Sep 26, 2023

what is a main idea of this MR?

@KolesnikDmitriy
Copy link
Collaborator Author

The main idea is fix documentation to avoid confusion of newcomers. They may start using defer after t.Require

@koodeex
Copy link
Collaborator

koodeex commented Sep 26, 2023

In common case it make sense but in that example the reason why defer stay there is to highlight semantic of WithTearDown function

It looks like common sense to me that you need to put it in the begging of Test

Let me think day or two about that

@KolesnikDmitriy
Copy link
Collaborator Author

fixed in #78

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

No branches or pull requests

3 participants