mirror of
https://github.com/logos-storage/asynctest.git
synced 2026-01-07 15:33:07 +00:00
Update documentation for setupAll and teardownAll
This commit is contained in:
parent
c4b23d73a9
commit
1ecce5d1a6
19
Readme.md
19
Readme.md
@ -33,14 +33,6 @@ proc someAsyncProc {.async.} =
|
|||||||
|
|
||||||
suite "test async proc":
|
suite "test async proc":
|
||||||
|
|
||||||
setupAll:
|
|
||||||
# invoke await in the suite setup:
|
|
||||||
await someAsyncProc()
|
|
||||||
|
|
||||||
teardownAll:
|
|
||||||
# invoke await in the suite teardown:
|
|
||||||
await someAsyncProc()
|
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
# invoke await in each test setup:
|
# invoke await in each test setup:
|
||||||
await someAsyncProc()
|
await someAsyncProc()
|
||||||
@ -55,6 +47,17 @@ suite "test async proc":
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
setupAll and teardownAll
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
The `setup` and `teardown` code runs before and after every test, just like the
|
||||||
|
standard [unittest][1] module. In addition we provide `setupAll` and
|
||||||
|
`teardownAll`. The `setupAll` code runs once before all tests in the suite, and
|
||||||
|
the `teardownAll` runs once after all tests in the suite. Use these only as a
|
||||||
|
last resort when setting up the test environment is very costly. Be careful that
|
||||||
|
the tests do not modify the environment that you set up, lest you introduce
|
||||||
|
dependencies between tests.
|
||||||
|
|
||||||
Unittest2
|
Unittest2
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,12 @@ template suite*(name, body) =
|
|||||||
|
|
||||||
suite name:
|
suite name:
|
||||||
|
|
||||||
# Runs before all tests in the suite
|
## Runs before all tests in the suite
|
||||||
template setupAll(setupAllBody) {.used.} =
|
template setupAll(setupAllBody) {.used.} =
|
||||||
let b = proc {.async.} = setupAllBody
|
let b = proc {.async.} = setupAllBody
|
||||||
waitFor b()
|
waitFor b()
|
||||||
|
|
||||||
# Runs after all tests in the suite
|
## Runs after all tests in the suite
|
||||||
template teardownAll(teardownAllBody) {.used.} =
|
template teardownAll(teardownAllBody) {.used.} =
|
||||||
template teardownAllIMPL: untyped {.inject.} =
|
template teardownAllIMPL: untyped {.inject.} =
|
||||||
let a = proc {.async.} = teardownAllBody
|
let a = proc {.async.} = teardownAllBody
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user