https://kotlinlang.org logo
#atrium
Title
# atrium
g

ghedeon

06/10/2018, 10:42 PM
what is your way of having a clean assertion of RxJava values? Do you use built-in assertions of TestObserver? Or something with atrium, like:
Copy code
fun posts(): Single<Foo>...
...
test:

val answer = foo().test().values().first()

//assert answer with atrium
this
.test().values().first()
looks a bit verbose, do you wrap it into an extension function? Just curious what's the best practice here
r

robstoll

06/12/2018, 8:11 PM
I am not using RxJava and hoped someone else would fill in. I am not too familiar with it. As I understand `foo()`makes the call which you want to test,
test()
is used to observe the value and
values().first()
is used to retrieve the value as such. I would probably create an assertion function for SingleSource<T> which wraps
test().values()
and retrieves
first
but also checks that
values()
hasSize(1)
(assuming it is somehow possible to emit two values even though it is defined as
Single<T>
. I hope that helps
Please let me know if you want to create an assertion function and need help
g

ghedeon

06/19/2018, 3:20 PM
Probably will do as you described, just decided to double check, what others are doing, must be a common pattern in RxJava world. Thanks for providing such a great support!
r

robstoll

06/19/2018, 7:57 PM
With pleasure and don't forget to Star Atrium on GitHub if you haven't done already
4 Views