Stateful testing: Compare SystemUnderTest to State?
andrewjstone opened this issue · comments
Hi,
I really like gopter so far. Thanks for providing such a useful library. I've just run into something unexpected with stateful testing though.
What I want is after each operation to not only compare the Result of the SystemUnderTest
command with the model state (State
) as in Postcondition
, but also to ensure that the internal state of the SystemUnderTest
is logically equivalent to the model state. I tried including a pointer to the SystemUnderTest
in State
so I could just perform this check in Postcondition
, but it appears that by the time Postcondition runs, the pointer is pointing to a different value than what was initialized and returned from NewSystemUnderTest
.
The rationale for this feature is to be able to test mutable methods on types that don't return values. So far I think the only workaround is to provide some introspection methods that we add as commands so we can then run and compare the output to the model state.
I was wondering if you could provide this capability, via another callback like invariant/1
in eqc_statem, or if there is a specific reason you think it should not be included. And yes, effort is a fine justification :) Thanks!
It looks like I can just return the SystemUnderTest
as part of Result
when Run
is called. That actually makes more sense than what I was originally trying to do. Sorry for the bother.