Thread
#atrium
    g

    ghedeon

    4 years ago
    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:
    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

    4 years ago
    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

    4 years ago
    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

    4 years ago
    With pleasure and don't forget to Star Atrium on GitHub if you haven't done already