-
Notifications
You must be signed in to change notification settings - Fork 107
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
State machine testing multiple results #113
Comments
Actually, fetchPart =
Command
{ commandGen = \(State knownParts) ->
case knownParts of
[] -> Nothing
_ -> Just (FetchPart <$> Gen.element knownParts) Would generate |
Hey sorry for the significantly delayed reply, I've been pondering this for a little while and I the best I could come up with was to introduce some commands which don't actually contact the external service, but which can be used to interrogate the So imagine if you had something like: -- Read :: Int -> [String] -> String
data Read v =
Read Int (Var [String] v) You'd be able to implement execute easily because that has access to the concrete I understand this is a bit clunky, but maybe we can iterate on the core mechanics of the idea and produce something a bit nicer. |
This seems to be my second comment, but that seems bad, because as I mentioned:
My command generator doesn't have access to the [String], so I can't take an element or calculate the length. This is presumably why you mentioned
But where do the elements (
Certainly, I think iterating on a concrete example might be easier. Essentially, the problem comes down to:
Shall I try and throw together a standalone example? |
Yeah that sounds great, I think part of the problem here is stemming from the fact that we don't have control over the results in the system under test. If we could add parts to the system or knew what they should be then we'd be able to populate our model (i.e. the |
https://github.com/ocharles/hedgehog-scenarios/tree/master/database-constraints is essentially one of the simplest problems that I've got so far. My external system here has some constraints, but generating commands that respects them isn't possible (in the way I've setup |
It's a bit disappointing to find this issue, and that it's still open, since I seem to have bumped into it as well -- my question on SO. |
Ooof, this hasn't got an answer? D: |
@spacekitteh Maybe not an answer, but #459 explains some of my current thoughts on this. |
I am doing a bit more playing with the state machine testing, in the context of testing work's REST API. For the purposes of this test, we have two end-points:
/parts?q=<q>
performs a search query and returns a list of parts that match the query q./part/<identifier>
looks up the part given asidentifier
.Internally, I know that performing a search consults an external service, and adds the search results to our local database. Therefore, I can start with a blank database, perform a search, and then lookup any of the parts that were returned. I'm trying to capture this with the following state:
The
search
command should update the list of parts with the result of the API call:But this doesn't type check!
response
is aVar [String] var
, butps
is[Var String var]
. It doesn't look like I will have any hope at reconciling the two if I keepvar
polymorphic and don't have anything more thanHTraversable
at my disposal. One vague idea would be to add a codensity-like transformation toSymbolic
, so we can at least have a working functor (HFunctor
?) for bothVar a Symbolic
andVar a Concrete
, which might be a good start.Any ideas what to do? Having
State { parts :: [Var [String] var] }
might be an option, but is not at all satisfactory 😢The text was updated successfully, but these errors were encountered: