airbnb/okreplay

OkReplay Annotation is too strict

christopherperry opened this issue · 5 comments

It takes an array of MatchRules. It should be an array of MatchRule so we can pass in custom rules and not one from the default set.

I think it's also a good idea to allow the use of multiple tapes, vs just a single tape.

FWIW you can set custom match rules via OkReplayConfig, but agreed, the annotation is too strict. We can replace it with MatchRule instead.

Ah, forgot why that's the case: Unfortunately annotation fields have to be compile time constants, that is interfaces are not allowed (https://kotlinlang.org/docs/reference/annotations.html):

Allowed parameter types are:

types that correspond to Java primitive types (Int, Long etc.);
strings;
classes (Foo::class);
enums;
other annotations;
arrays of the types listed above.

Bummer 😢

classes (Foo::class); would work given Foo is an implementation of MatchRule. This should be doable.

I think by "classes", it means the Class class, not an instance of any class:
image
image