aleeusgr / gimbalabs-dandelion-pbl

Test Driven Development of dApps on Cardano
MIT License
1 stars 1 forks source link

write an artifact to understand what QuickCheck does. #3

Closed aleeusgr closed 1 year ago

aleeusgr commented 1 year ago

Discussion

Some input on how to test plutus contracts using a ContractModel. That is, use a QuickCheck model to automatically generate test cases for your plutus contract.

https://plutus-apps.readthedocs.io/en/latest/plutus/tutorials/contract-testing.html https://plutus-apps.readthedocs.io/en/latest/plutus/tutorials/contract-models.html

Note that you do not necessary need to use the contract monad in plutus-apps, even though the tutorials do use this for their testing approach. Just ping Quviq if you want to get automatic test case generation in a different setting.

aleeusgr commented 1 year ago

Ok, here I wrote a test by hand, in the process I looked into how cabal test works

Here is a property check;

Looking at the tutorial, I should reproduce the results. What framework I should use?

Quick check

aleeusgr commented 1 year ago
Tasty https://haskell-at-work.com/episodes/2018-01-13-dynamic-test-suites-in-haskell-using-hspec-and-tasty.html https://github.com/qfpl/tasty-hedgehog
aleeusgr commented 1 year ago

Property testing is a testing technique where, instead of asserting that specific inputs produce specific expected outputs, the practitioner randomly generates many inputs, runs the program on all of them, and asserts the truth of some "property" that should be true for every pair of input and output.

Property testing libraries allow the user to control the strategy by which random inputs are constructed, to ensure coverage of degenerate cases, or inputs featuring specific patterns that are needed to fully exercise aspects of the implementation under test. source

aleeusgr commented 1 year ago

https://github.com/aleeusgr/gimbalabs-dandelion-pbl/commit/626939e8dffd6f34b5a0e8ab7295e66ad3e7f272