java - Test observable evaluated only once -


we using rx-java, have problem test if observable evaluated once.

we have following signature of services:

class {   observable<string> computea(); }  class b {   observable<void> computeb(string inputa) }  class c {   observable<void> computec(string inputa) } 

in our case have service invokes service a, , use result of service input 2 service b , c. want check service in invoked once.

we tried using atomicinteger counter mocking observable of service or mocking observable.onsubscribe checking times call invoked, test turns difficult read.

the question is: there cleaner way kind of test?

we adding

source .doonsubscribe(() -> counter.getandincrement()) .op() .op() ... 

at required place , check counter value after things quiet down.

note have operator called publish() makes sure source subscribed once , side-effects of happen once (as long connect() called once).


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -