1
0
mirror of https://github.com/actix/actix-website synced 2025-02-17 10:13:31 +01:00

Testing: Mention the potential need for run_on (#118)

This commit is contained in:
Danilo Bargen 2019-10-14 01:58:48 +02:00 committed by Yuki Okushi
parent 73b0ac0702
commit 0747220bbb

View File

@ -33,6 +33,15 @@ regular `App` builder.
{{< include-example example="testing" file="integration_one.rs" section="integration-one" >}} {{< include-example example="testing" file="integration_one.rs" section="integration-one" >}}
Note: If you get the error message "no Task is currently running" when running your
test, you may need to wrap your service call in
[test::run_on](https://docs.rs/actix-web/1/actix_web/test/fn.run_on.html):
```rust
let future = test::run_on(|| app.call(req));
let resp = test::block_on(future).unwrap();
```
If you need more complex application configuration testing should be very similar to creating If you need more complex application configuration testing should be very similar to creating
the normal application. For example, you may need to initialize application state. Create an the normal application. For example, you may need to initialize application state. Create an
`App` with a `data` method and attach state just like you would from a normal application. `App` with a `data` method and attach state just like you would from a normal application.