문제

I have a spec for a class which uses a stubbed collaborator. Now in my class (let's say class A), I do some manipulation on the collaborator class name (let's say class B) to transform it's own class name into something useful for the class. Problem is: the stubbed collaborator "class B" in the spec is not the real class, but a prophecy object. I'm not in control of the object i'm mocking because it's in a third party library, and I can't provide a getName() or getSignature from it.

Is there a way to extract the original class being doubled in a prophecy object?

도움이 되었습니까?

해결책

Yes, you can

Instead of passing the actauly Collaborator (the prophecy object), call getWrappedObject() on your collaborator, and pass the result of that. getWrappedObject() will return the original object that is wrapped by the collaborator.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top