Skip to content
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

Add a getting started tutorial #119

Closed
dubzzz opened this issue Jun 11, 2018 · 7 comments
Closed

Add a getting started tutorial #119

dubzzz opened this issue Jun 11, 2018 · 7 comments

Comments

@dubzzz
Copy link
Owner

dubzzz commented Jun 11, 2018

Content:

  • explain property based
  • example sort: from project setup to properties
@bitjson
Copy link
Contributor

bitjson commented Jun 12, 2018

This would be very helpful. 💯

Particularly, I'd really appreciate a succinct example for the more QuickCheck-like use case, where you're exercising functionality in lots of random orders to find strange issues. I have a todo test here which I'd love to know the most idiomatic way to accomplish with fast-check.

I already did some simple "input -> result" fast-check assertions in that file (to ensure compatibility with other implementations of secp256k1), but I actually only found this bug in manual testing.

Returned Typed Arrays were using references to internal buffers rather than copies of them, so if you used library methods in a certain order, and continued trying to use earlier results, your earlier results were continuing to be modified by the library (since I was accidentally giving you a reference rather than a copy). I'd love to see an example which uses fast check to try all the various different methods in many orders, and confirm that we still get reasonable results.

@dubzzz
Copy link
Owner Author

dubzzz commented Jun 12, 2018

Partial answer for the moment, I need to dig a little bit more in your message before coming with a full answer.

Concerning:

I'd love to see an example which uses fast check to try all the various different methods in many orders, and confirm that we still get reasonable results.

I have an opened issue #8 to implement commands-like approach - model based testing. I have seen this method in used with RapidCheck C++.

Snippet example (C++ code): https://github.com/emil-e/rapidcheck/blob/master/examples/counter/main.cpp
More details at: https://labs.spotify.com/2015/06/25/rapid-check/

Basically you define commands with:

  • preconditions
  • run

And your done ;) The framework does all the magic for you.

It is really a feature I want to see in fast-check, so I will definitely work on it whenever I got enough time to think of a nice implementation. I want to apply this approach for UI testing (I already built a POC for that at work based on fast-check).

@dubzzz
Copy link
Owner Author

dubzzz commented Jun 12, 2018

@bitjson I just submitted an example of simple implementation of model based testing based on fast-check. See Model based testing example #120

For the moment, I do not provide a built-in implementation in the framework. It would require some more work:

  • fc.array is not suitable for a quick shrink on commands - we can truncate the array right after the first failure
  • need to deal with asynchronous code for real implementation and maybe for model - still doing experiments to check if it is needed on model side

Related to your point:

I'd love to see an example which uses fast check to try all the various different methods in many orders, and confirm that we still get reasonable results.

@dubzzz
Copy link
Owner Author

dubzzz commented Jun 13, 2018

In reality, given #120, there is very few work to do to have a ready to use solution. If it solves your problem I can start adding this feature to fast-check in a next minor.

Basically, I can:

  • start by taking this code
  • keep using fc.array for the moment
  • add an async implementation for the executor

And this is it.

dubzzz added a commit that referenced this issue Jun 14, 2018
dubzzz added a commit that referenced this issue Jun 14, 2018
@dubzzz
Copy link
Owner Author

dubzzz commented Jun 14, 2018

@bitjson Just added a hands-on tutorial containing both a definition of property based and a sample project example tested with fast-check. Available directly from the README

@bitjson
Copy link
Contributor

bitjson commented Jun 15, 2018

@dubzzz awesome! Thanks for the examples, those are both very helpful.

And I would love to be your first user for a built-in model based testing framework! Just let me know when you have something ready for me to try – I'll try it on the Secp256k1 interface in bitcoin-ts.

@dubzzz
Copy link
Owner Author

dubzzz commented Jun 15, 2018

Closing the issue. There is an open issue to keep track on the model based way

@dubzzz dubzzz closed this as completed Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants