We are still experimenting with the best way to test Motoko and canisters. There are several tools around today that can help with unit testing:
- Built-in assert: see examples from the base library: motoko-base/test at master · dfinity/motoko-base · GitHub
- The Motoko matcher library: GitHub - kritzcreek/motoko-matchers. It’s best to test with library code, i.e. without service actors.
- ic-repl: GitHub - chenyan2002/ic-repl. This is designed at the canister level, so that you can use the tool to call canisters written in different languages. It’s also useful if you want to seed data or write scripts.