...by Daniel Szego
"Simplicity is the ultimate sophistication."
Leonardo da Vinci

Monday, December 18, 2017

Solidity and Truffle Tips and Tricks - Unit testing

In Truffle there are two unit testing framework, unit testing with solidity with special testing contracts and unit testing with a javascript unit testing framework called Mocha. You can actually use the mixture of both. However, solidity unit testing is pretty much in a beta phase, besides the language was not really designed to write unit tests, like you should define one contract for each test in a separate file paying especially attention to the file name, having difficulty to make console logs during running the tests and so on. As a consequence, Mocha is proposed whenever it is possible, perhaps with one big exception: if the contracts should be unit-tested not from the end-user perspective but explicitly from another contract.