jeffh / Fox

Property Based Testing Library for Objective-C and Swift. QuickCheck for Apple's Platforms.
http://fox-testing.rtfd.org
Other
624 stars 30 forks source link

README: More detailed example of stateful testing? #6

Closed modocache closed 9 years ago

modocache commented 9 years ago

Around the 4'00" mark of this video on QuickCheck, John Hughes demonstrates testing the state of a queue, complete with pre-conditions and post-conditions. How would I model such a thing in PBT?

jeffh commented 9 years ago

https://github.com/jeffh/PBT/blob/master/PBTSpecs/Public/Generators/PBTFiniteStateMachineSpec.mm

You conform to the PBTStateTransition Protocol for each state transition. It's not as elegant as erlang, but it is functional. See PBTQueueRemoveTransition.

Also: concurrent & async state machine test generators are currently not implemented.

modocache commented 9 years ago

Ah! Gotcha. Silly me, I thought the "custom transition" in the README was made as some sort of convenience, not as the primary means by which to implement stateful testing. I'll take a harder look at PBTStateTransition, and PBTQueueRemoveTransition in particular.

Thanks a million! :tophat:

jeffh commented 9 years ago

If you happen to figure out a better way to succinctly describe transitions without defining a new class as opposed to my lousy PBTTransition. I'd love a PR.