Multiple behaviors for one invocation
Closed this issue · 2 comments
tibr commented
When calling
behave(stub, interaction(), foo)
behave(stub, interaction(), bar)
the stub will always return foo
. I would have expected it to return bar
. Additionally, we could log a warning that informs the user about multiple behaviors for the same interaction and the resulting return value.
My current workaround looks like this:
behave(stub, interaction(), foo)
stub.behavior = []
behave(stub, interaction(), bar)
Maybe we should also add a more obvious way to reset behaviors for a stub?
felixvisee commented
Yo, I was also thinking about adding more ways to define behavior, like:
behave(stub, interaction(any(), value(1), filter { ... })) { arg1, arg2, arg3 in
return returnValue
}
However, since stub invocations are currently not restricted to values only, we cannot guarantee that all of arg1
, arg2
, and arg3
are actually values. But maybe that would be a good idea?!
felixvisee commented
To be fixed by #11.