Writing unit tests with Solidity
Before we start the exercises in this chapter, let's do the usual housekeeping:
- Inside your
truffle-practice
folder, create a new folder calledchapter6
Great! That's it. Let's get started with this chapter. Now, we've already built a few mini applications, so which one should we write tests for? Let's write tests for the mini-application we wrote in Chapter 1, Truffle for Decentralized Applications. Why? There are two reasons:
- The Chapter 1, Truffle for Decentralized Applications, project contains fundamental Solidity elements that we should write tests for.
- The Chapter 1, Truffle for Decentralized Applications, project does not rely on a particular JavaScript framework. Since it's in VanillaJS, you can just focus on writing unit tests without worrying about framework-specific caveats.
Since we are writing tests for the Chapter 1, Truffle for Decentralized Applications, application, let's copy the contents of our chapter1
folder into our chapter6
folder. Then...