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

♻️ parameterize tests #31

Merged
merged 3 commits into from
Feb 28, 2023
Merged

♻️ parameterize tests #31

merged 3 commits into from
Feb 28, 2023

Conversation

jvdd
Copy link
Owner

@jvdd jvdd commented Feb 28, 2023

Closes #30, should in general "remove" a lot of duplicate unit test code :)

  • parameterize unit tests
    • limit duplicate code using generic functions from test_utils.rs
    • place unit tests at the bottom of each file (instead of between the code - at the end of the sub-mods)
  • parameterize integration tests

Decided to keep the tests in each file as this seems the best practice in Rust - see quote from the book

You’ll put unit tests in the src directory in each file with the code that they’re testing. The convention is to create a module named tests in each file to contain the test functions and to annotate the module with cfg(test).

However, I placed the tests at the bottom of each file (which should significantly enhance the code readability) + limited duplication of tests through using parameterization & centralized generic code (in test_utils.rs).

Long story short, this PR should improve the maintainability & flexibility of the tests!

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 28, 2023

CodSpeed Performance Report

Merging #31 improve_tests (6975eaf) will not alter performances.

Summary

🔥 0 improvements
❌ 0 regressions
✅ 52 untouched benchmarks

🆕 0 new benchmarks
⁉️ 0 dropped benchmarks

@jvdd jvdd merged commit 3891540 into main Feb 28, 2023
@jvdd jvdd deleted the improve_tests branch February 28, 2023 21:16
@jvdd jvdd mentioned this pull request Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve unit tests
1 participant