https://github.com/nikvolf/gtest-min
Minimal example for `cargo gtest`
https://github.com/nikvolf/gtest-min
Last synced: 3 days ago
JSON representation
Minimal example for `cargo gtest`
- Host: GitHub
- URL: https://github.com/nikvolf/gtest-min
- Owner: NikVolf
- License: mit
- Created: 2024-03-08T17:06:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-08T17:24:08.000Z (over 2 years ago)
- Last Synced: 2025-10-26T18:40:02.771Z (8 months ago)
- Language: Rust
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gtest-min
Minimal example for `cargo gtest`.
Try it by running:
`cargo gtest`
or
`cargo gtest --release`
(Install `cargo-gtest` via `cargo install --git https://github.com/NikVolf/onchain-tests`)
## What is minimal
- Dependencies on test-runtime:
```toml
gear-test-codegen = { git = "https://github.com/nikvolf/onchain-tests" }
gear-test-runtime = { git = "https://github.com/nikvolf/onchain-tests" }
```
- Build dependency (improved version of `gear-wasm-builder`):
```toml
gear-ext-builder = { git = "https://github.com/nikvolf/onchain-tests" }
```
## Using
As you can see in `src/tests.rs`, tests are declared with simple decorator!
```rust
#[gear_test_codegen::test]
async fn good(context: &gear_test_runtime::SessionData) {
let this = create_this(&context.testee()).await;
let result: Vec = msg::send_bytes_for_reply(this, b"PING", 0, 0)
.expect("failed to send")
.await
.expect("Program to handle simple PING!!1");
assert_eq!(result, b"PONG")
}
```