RxTest icon indicating copy to clipboard operation
RxTest copied to clipboard

Writing marble tests

Open jmfayard opened this issue 7 years ago • 13 comments

Hello, what I lack when testing rx java things is the ability to quickly produce input observables.

RxJs has super cool functions to produce those

cold("--a--b--#"): On frame 20 emit a, on frame 50 emit b, and on frame 80, error`

hot("-a-^-b--|"): In a hot observable, on frame -20 emit a, then on frame 20 emit b, and on frame 50, complete.

https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md

something like that in kotlin would be super valuable

jmfayard avatar Jan 18 '18 10:01 jmfayard

Looks interesting, thank you.

RubyLichtenstein avatar Jan 18 '18 11:01 RubyLichtenstein

Hi @jmfayard

Do you want to work on this feature?

RubyLichtenstein avatar Feb 04 '18 09:02 RubyLichtenstein

@RubyLichtenstein I can contribute what I already did. I fear I don't understand enough rxjava to make it right by myself though

jmfayard avatar Feb 04 '18 10:02 jmfayard

Great, so please fork the project and add what you all ready done

What about porting the JavaScript code to kotlin code?

RubyLichtenstein avatar Feb 04 '18 10:02 RubyLichtenstein

We should steal their ideas, not their code. A lot of how it's implemented rely on how javascript works. e.g you don't have dynamic types on the JVM.

jmfayard avatar Feb 04 '18 10:02 jmfayard

I think we should take what we can from the js code. We shouldn't do work that already done Its not stealing if its open source :)

RubyLichtenstein avatar Feb 04 '18 10:02 RubyLichtenstein

https://github.com/ReactiveX/rxjs/blob/master/src/internal/testing/TestScheduler.ts

RubyLichtenstein avatar Feb 04 '18 10:02 RubyLichtenstein

Most of the code should be the same

RubyLichtenstein avatar Feb 04 '18 10:02 RubyLichtenstein

I meant stealing in a positive sense, like T.S. Eliott quote Good artists copy; great artists steal.

jmfayard avatar Feb 04 '18 10:02 jmfayard

https://github.com/RubyLichtenstein/RxTest/pull/19

jmfayard avatar Feb 04 '18 12:02 jmfayard

Great job!

I'll review it as soon as I have time

RubyLichtenstein avatar Feb 06 '18 13:02 RubyLichtenstein

So the work you did is not based on the js implementation?

RubyLichtenstein avatar Feb 06 '18 13:02 RubyLichtenstein

no, I didn't have the code of the js implementation at that time.

jmfayard avatar Feb 06 '18 16:02 jmfayard