在這一步驟中,我們將查看我們編寫的所有不同的單元測試,以覆蓋我們在步驟 4 中編寫的程式碼。我們還將查看一些可以用來幫助我們編寫程式碼的工具測試。
首先,運行資料夾package test中的命令step_5/BasicCoin
move test
你應該看到這樣的東西:
BUILDING BasicCoin
Running Move unit tests
[ PASS ] 0xcafe::BasicCoin::can_withdraw_amount
[ PASS ] 0xcafe::BasicCoin::init_check_balance
[ PASS ] 0xcafe::BasicCoin::init_non_owner
[ PASS ] 0xcafe::BasicCoin::publish_balance_already_exists
[ PASS ] 0xcafe::BasicCoin::publish_balance_has_zero
[ PASS ] 0xcafe::BasicCoin::withdraw_dne
[ PASS ] 0xcafe::BasicCoin::withdraw_too_much
Test result: OK. Total tests: 7; passed: 7; failed: 0
看一下 BasicCoin模組中的測試,我們試著讓每個單元測試都測試一種特定的行為。