Skip to content

Commit

Permalink
Merge branch 'master' into kkawula/2508-update-account-create-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kkawula authored Oct 1, 2024
2 parents 7bdee5d + 9d9f2ab commit 45aee71
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/src/testing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,26 @@ Tests: 0 passed, 0 failed, 0 skipped, 1 ignored, 0 filtered out

To run only tests marked with the `#[ignore]` attribute use `snforge test --ignored`.
To run all tests regardless of the `#[ignore]` attribute use `snforge test --include-ignored`.

## Writing Assertions and `assert_macros` Package
> ⚠️ **Recommended only for development** ️⚠️
>
>***Assert macros package provides a set of macros that can be used to write assertions such as `assert_eq!`.
In order to use it, your project must have the `assert_macros` dependency added to the `Scarb.toml` file.
These macros are very expensive to run on Starknet, as they result a huge amount of steps and are not recommended for production use.
They are only meant to be used in tests.
For snforge `v0.31.0` and later, this dependency is added automatically when creating a project using `snforge init`. But for earlier versions, you need to add it manually.***

```toml
[dev-dependencies]
snforge_std = ...
assert_macros = "<scarb-version>"
```

Available assert macros are
- `assert_eq!`
- `assert_ne!`
- `assert_lt!`
- `assert_le!`
- `assert_gt!`
- `assert_ge!`
4 changes: 4 additions & 0 deletions docs/src/testing/using-cheatcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ When testing smart contracts, often there are parts of code that are dependent o
Instead of trying to replicate these conditions in tests, you can emulate them
using [cheatcodes](../appendix/cheatcodes.md).
> ⚠️ **Warning**
>
> These examples make use of `assert_macros`, so it's recommended to get familiar with them first. [Learn more about `assert_macros`](testing.md#writing-assertions-and-assert_macros-package)
## The Test Contract
In this tutorial, we will be using the following Starknet contract:
Expand Down

0 comments on commit 45aee71

Please sign in to comment.