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

Improve Tests using TestMain() #142

Closed
rokath opened this issue Sep 23, 2021 · 3 comments
Closed

Improve Tests using TestMain() #142

rokath opened this issue Sep 23, 2021 · 3 comments
Assignees
Labels
quality improve code quality Testing
Milestone

Comments

@rokath
Copy link
Owner

rokath commented Sep 23, 2021

Can set global vars to different values and repeat the call of m.Run() but this will cause some tests to be called parallel and result in some fails. Needs further investigation. See file update_whitebox_test.go as example.

@rokath rokath added the quality improve code quality label Sep 23, 2021
@rokath rokath self-assigned this Sep 23, 2021
@rokath rokath added this to the version 1.0 milestone Sep 24, 2021
@rokath
Copy link
Owner Author

rokath commented May 21, 2022

Joined with #286

@rokath rokath closed this as completed May 21, 2022
@rokath rokath reopened this May 23, 2022
@rokath rokath added the Testing label May 23, 2022
@rokath
Copy link
Owner Author

rokath commented Jun 20, 2022

Reduce global variables. CLI parameter values could be in function parameters for testing. For cleaner function interfaces use wrapper functions. Not sure if the is a good idea.

@rokath
Copy link
Owner Author

rokath commented Jul 22, 2024

Each package is compiled for testing in a separate binary and they are tested are tested parallel. The tests inside a package are tested sequentially. Therefore each test needs to set the global variables it uses. That is implemented in the id package tests. Test Main() could be used if packages share the same external resource, like til.json. Because we use afero for the tests, this is right now no issue anymore.

@rokath rokath closed this as completed Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality improve code quality Testing
Projects
None yet
Development

No branches or pull requests

1 participant