You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update persistence-testing.md docs
Fixed a few typo's
Added more explicit code example with regards to working with custom interceptors.
Added link to the akka.hosting integration testing page from the bootcamp. Regarding more advanced integration testing.
* satisfy spellchecker
* Satisfy linter
* Update persistence-testing.md
---------
Co-authored-by: Aaron Stannard <[email protected]>
Copy file name to clipboardExpand all lines: docs/articles/persistence/persistence-testing.md
+42-2
Original file line number
Diff line number
Diff line change
@@ -133,7 +133,7 @@ public class CounterActorTests : PersistenceTestKit
133
133
}
134
134
```
135
135
136
-
When we will launch this test it will fail, because the persistence journal failed when we tried to tell `inc` command to the actor. The actor failed with the journal and `read` was never delivered anb we had not received any answer.
136
+
When we will launch this test it will fail, because the persistence journal failed when we tried to tell `inc` command to the actor. The actor failed with the journal and `read` was never delivered and we had not received any answer.
137
137
138
138
### How to Make Things Better
139
139
@@ -205,7 +205,19 @@ Out of the box, the package has the following behaviors:
205
205
206
206
All methods have additional overload to add artificial delay - `*WithDelay`, i.e. `FailWithDelay`. This could be helpful to simulate network delay or retry of physical persistence operation within the journal.
207
207
208
-
When all mentioned above behaviors are not enough, it is always possible to implement custom one by implementing the `IJournalInterceptor` interface. An instance of a custom interceptor can be set using the `SetInterceptorAsync` method.
208
+
When all mentioned above behaviors are not enough, it is always possible to implement a custom one by implementing the `IJournalInterceptor` interface. An instance of a custom interceptor can be set using the `SetInterceptorAsync` method.
Sometimes you might want to verify more complex scenario's for your persistent actor. For example, your actor might persist events only under certain conditions and you want to test that.
262
+
An easy way to do that is by implementing a custom interceptor, either a Journal or a Snapshot interceptor depending on your needs.
263
+
You could have that interceptor then collect the events or snapshots being persisted and assert on the data in that interceptor.
264
+
Depending on your needs you can make this as complicated or simple as you want.
Should you run into race conditions, between executing your test code and performing the assertions. Wrapping your assertion code in a `AwaitAssert` call would be a good way to manage that.
282
+
283
+
### Integration Testing
284
+
285
+
Lets say you need more then just the InMemory persistence model. There is a bootcamp and corresponding video on those subjects that are well worth checking out. [Integration testing with Akka.Hosting](https://petabridge.com/bootcamp/lessons/unit-1/akka-hosting-testkit/)
0 commit comments