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

Add default function implementations for the ModelState trait #3

Open
nickelization opened this issue Jun 28, 2023 · 0 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@nickelization
Copy link
Contributor

nickelization commented Jun 28, 2023

Currently you have to implement every function in ModelState, even if you don't care about things like post-test cleanup or postconditions. It's probably worth making default no-op implementations of those functions so that tests can skip implementing ones that they don't need. (For an example of a case like this, see tests/counter.rs.)

Note, however, that I specifically do not want to add default implementations for preconditions_met; we could easily add a default function that returns true, but I think it would be unusual for a real-world test to not care about preconditions, and if you don't specify any then the test may appear to work fine until you find a failure and get bad results from shrinking. As such, I think it 's important to be explicit about it if you really don't want to define any preconditions. Similar logic applies to next_state, in my opinion.

As such, the functions I'm envisioning default implementations for are:

  • check_postconditions
  • clean_up_test_run
  • init_test_run (though we might need to change the API to require Default on ModelState::RunContext in order to be able to make a sane default implementation for this one, and then that forces us to implement Default on all run context types which seems excessive and annoying...so maybe not? TBD)
@nickelization nickelization added enhancement New feature or request good first issue Good for newcomers labels Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant