Spy on existing classes
Rather than mocking an object, you can create spies of real objects. Spies will run the real methods in a class, unlike mocks which don’t run anything. Stubbing methods on a spy will run the stub instead, so you can have a mixture of real methods and stubbed methods.
Spies get their name because you can spy on the code you’re testing and see what methods it called. Spies let you verify that a method is called, just like a mock.
当前内容版权归 Tiger Oakes 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Tiger Oakes .