-
Notifications
You must be signed in to change notification settings - Fork 25
What should mock be used for #236
Comments
The way Why Most importantly, is that it solves the problem of allowing more than one Another reason for not removing it is, because I've also played around with the Does that make sense? I'll update the README to include more info about |
I have seen internal implementation and noticed some state counter, so I guess this is what you are saying here
Esentially you are saying that
ok - this is where you answered it :) . Yes, I figured that out by trying to modify mock :: Model Symbolic -> Action Symbolic -> GenSym (Response Symbolic)
-- mock (Model Nothing) TakeTicket = error "mock: TakeTicket"
-- mock (Model (Just n)) TakeTicket = GotTicket <$> pure n
mock _ _ = pure ResetOk but it produced correct output (test passed) in both cases. That's when I figured my understanding about this feature is still vauge but I see it is still WIP
it does - thanks <3
why I was confused about data Action r = ReadFileA
data Response r = ReadFileR (Either SomeError Text)
data Model r = Model Text I am not sure how I could mock up all errors that can happen. Do I have to mock up all cases mock :: Model Symbolic -> Action Symbolic -> GenSym (Symbolic Response)
-- non happy path
mock model ReadFileA =
-- somehow figure out how all error cases can happen and model all of them.
-- what if we leave out some error case?
-- maybe IO error happens depending on some OS internals. Do I have to capture that?
return $ ReadFileR $ Left $ ...
-- happy path
mock (Model t) ReadFileA = return $ ReadFileR $ Right t (the above won't compile but I guess you see where I am aiming at) or would it be sufficient to mock only happy paths (which seems viable): mock :: Model Symbolic -> Action Symbolic -> GenSym (Symbolic Response)
mock (Model t) ReadFileA = return $ ReadFileR t ? This is a toy example, but its motivated by my real life example where https://github.com/input-output-hk/cardano-sl/pull/3772/files#diff-3b681d025c5691ef4161a3e2d29ebea3R69 we are modeling some action, wallet creation by Or more complex example is testing a black box system like John Hughes testing dropbox https://www.youtube.com/watch?v=H18vxq-VsCk . I am not sure he would be able to find all wrong paths (not even all happy paths) with a black box approach. I hope you see where my confusion is comming from: mock all paths or only "simple" paths :) |
When I said:
I should have added that the only important part is that I'll make sure to mention both these things when I update the README! Regarding how to Perhaps only happy path is enough? Perhaps there should be fault injection commands which steer the unhappy paths? I don't know yet... But for now, while If you have any ideas on the topic, I'm all ears, :-). |
Thanks for prompt replays. I will have to dive deeper into implementation details to capture full understanding of underlying mechanics. There is also mention of few papers in README that I'll have to read to get a full picture (hopefully by end of the year!). Will give my feadback eventually (based on our use case) |
Feel free to ask questions or open further issues if there's something you'd like explained better in the documentation! I'm happy to explain things further, especially during working hours :-). Also, I'm looking forward to hear your feedback! |
I am not sure what should be
mock
, last parammeter toStateMachine
be used for and how it is used in a current implementation?This line is onpar with my understanding https://github.com/advancedtelematic/quickcheck-state-machine/blob/master/test/Echo.hs#L146
Also I can't deduce why
mock
would be needed from readme section on hackage:The text was updated successfully, but these errors were encountered: