This chapter will introduce you to the importance of thoroughly testing your smart contracts, as well as various techniques and approaches for successfully testing a Truffle application. Specifically, this chapter will cover how to write comprehensive unit tests in Solidity and JavaScript, as well as the correct method for testing modifiers and reverts. Moreover, this chapter will illustrate how to test for events being thrown in your Solidity contract too. You will also learn about fundamental concepts, such as transaction objects and parameters, when working with truffle-contract and web3.
In particular, you will learn how to do the following:
- Write comprehensive unit tests in Solidity
- Write comprehensive unit tests in JavaScript
- Test Solidity events
Unit tests are a great way to test whether your contract works as expected, rather than learning the hard...