Add a template for a group of methods from one module#335
Open
bugRanger wants to merge 5 commits into
Open
Conversation
Owner
|
It's a way to implement what we called contract tests ... now this name is used for something different but the idea is "I would test the trait contract against different implementation". Lot of years ago it was possible in rust import the same module file from different source code and I used this "wrong behaviour" to load different fixture from the same test file. Anyway, I love this idea. I have to fix the CI... I guess 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'd like to share a solution to the problem of writing identical tests.
My project uses multiple implementations of the same trait. All tests have the same logic for verifying the behavior of the trait implementation; the only difference is in the
#[fixture]section, where the implementation under test is selected.The solution I propose is similar to
#[template], except that we create a template for the entire module and, in this module, mark the methods that should be excluded from the template. The excluded methods are expected to be implemented with the necessary modifications wherever the template is used.