Skip to content

Commit

Permalink
update unit test (#3219)
Browse files Browse the repository at this point in the history
  • Loading branch information
geometryolife authored Jan 22, 2025
1 parent e2079bb commit 22ba155
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/website/pages/build/rooch-framework/unit-test.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,19 @@ Test result: FAILED. Total tests: 1; passed: 0; failed: 1
```
As you can see, the Move compiler clearly indicates the location of the assertion program, so we can easily locate a certain location in our test program and know that the execution result of a certain function does not meet our expectations.
## Rooch Framework Test
When using Rooch Framework to test code, you need to call the init_for_test() function.
For example:
```move
#[test_only]
/// init the genesis context for test
public fun init_for_test(){
rooch_framework::genesis::init_for_test();
let genesis_account = moveos_std::signer::module_signer<GenesisContext>();
init(&genesis_account);
}
```
16 changes: 16 additions & 0 deletions docs/website/pages/build/rooch-framework/unit-test.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,19 @@ Test result: FAILED. Total tests: 1; passed: 0; failed: 1
```
可以看到,Move 编译器很清楚地指明了断言程序的位置,因此我们就能很容易地定位到我们测试程序的某个位置,进而知道某个函数的执行结果没有达到我们的预期。
## Rooch Framework 测试
使用 Rooch Framework 对代码测试时,需要调用 `init_for_test()` 函数。
例如:
```move
#[test_only]
/// init the genesis context for test
public fun init_for_test(){
rooch_framework::genesis::init_for_test();
let genesis_account = moveos_std::signer::module_signer<GenesisContext>();
init(&genesis_account);
}
```

0 comments on commit 22ba155

Please sign in to comment.