Last updated
Last updated
We wrote our contract, it compiles but how to be sure if it works as it should ? The contract will handle real money, you can't simply deploy it and say "we will see lol".
You SHOULD have a testing process, it will allow you two things :
Ensure your code works
Appease your mind every time you make changes on your code, how to be sure you didn't break something with your changes ?
There is two way to test your contract :
The naïve way : you deploy it on the devnet and manually try each features. Cons : this is time consuming, possibles human mistakes like forgetting specific cases or using wrong tests parameters, every one can see your tests since devnet is public (you can have your own devnet but this is time consuming), you cannot control your test environment since the devnet state changes between two tests, ... Pros ? No one
The golden way : you created automated tests you can run in a second and they will tell you if everything is ok. No need to spend hours deploying and testing your contracts, have automated tests allow you to build and deliver faster and safer.
At the moment, the only way to have automated tests in mx-sdk-as is via scenario.
Explaining scenario is out of this tutorial's scope, if you did the you should already be able to use scenario.
Scenario tests for the flip contract will be available on along with the full contract code.
This tutorial is now finished. The contract code with scenario tests can be found . If you have any question feel free to ask me via DM on my GitHub or Twitter account. Thanks for reading this !
More important than writing code, testing it !