Skip to content

Add default function implementations for the ModelState trait #3

@nickelization

Description

@nickelization

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions