Skip to content

Commit 5ac42ac

Browse files
committed
docs(test): add test cli autodoc and userguide
1 parent 8402d52 commit 5ac42ac

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

docs/commands/run.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ CLI commands for local development of running Silverback bots and task workers.
66
:prog: silverback run
77
:nested: none
88

9+
.. click:: silverback._cli:test
10+
:prog: silverback test
11+
:nested: none
12+
913
.. click:: silverback._cli:worker
1014
:prog: silverback worker
1115
:nested: none

docs/userguides/development.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,31 @@ The client will send tasks to the 2 worker subprocesses, and all task queue and
306306

307307
## Testing your Bot
308308

309-
TODO: Add backtesting mode w/ `silverback test`
309+
You can test your bot across various ranges of history using the [`silverback test`](../commands/test) command to perform "backtesting".
310+
Backtesting is a super useful technique to measure the performance of your bot by checking it against different periods of history to see how it would react.
311+
Silverback has provisional support for special backtest cases that must have a name like `backtest_*.yaml` under your `tests/` folder in your project.
312+
313+
Here is an example test case:
314+
315+
```yaml
316+
# `bots` key is optional, defaults to `bot:bot` if omitted
317+
bots: "<bot name>"
318+
# can also use array of bot names, or "*" for all bots under `bots/`
319+
320+
# required, recommended to be a public network
321+
network: "ethereum:mainnet"
322+
323+
# recommended to pick a small range of blocks for your case
324+
start_block: 15_338_009
325+
stop_block: 15_338_018
326+
327+
# NOTE: Ignores extra data
328+
something_else: blah
329+
```
330+
331+
In a complex project (where your bot(s) are not the only component), it is recommended to place your backtests under a separate folder such as `tests/backtest/`.
332+
This will allow you to run backtests separately from your other tests as they take a long time to execute.
333+
Further, you can use any pytest arguments to help select your tests, for example using `-k <bot-name>` in a [test matrix](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#using-a-matrix-strategy), if you have multiple bots to test.
310334

311335
## Deploying your Bot
312336

0 commit comments

Comments
 (0)