Verifying side effects in unit tests #3673
Unanswered
TomRHandcock
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Is there a particular reason for this? This looks a bit like duplication. Your repository probably does not need extra state management. class BookListRepository {
void setBookFavorite(String id, bool favorite) {
// Update persistent storage.
}
...
}
@riverpod
// or any other SL solution
BookListRepository bookRepo(BookRepoRef ref) => BookListRepository(); |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello folks,
I am part of a project where we have decided to try out riverpod for state management instead of our traditional choice of bloc and so far, we are finding it great to use. I'm sure once things become more 'second nature' we'll be able to implement features quickly and concisely with riverpod offering features such as caching out of the box.
For a bit of context, our chosen architecture is to 'chain' providers to allow for abstraction of our presentation layer from our domain/service layers.
When it comes to unit testing these providers, we want to be able to assert two critical things:
The first point is covered readily in the documentation however we haven't been able to identify a solution to the second point, when side effects trigger interactions with other notifiers.
In other words, if a side-effect in
NotifierA
triggers a side-effect inNotifierB
, how does one verify this in unit tests?Many thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions