Use the Factory mode to create MOCK

xiaoxiao2021-03-06  23

If you use IOC to be relatively simple with MOCK, sometimes it is not easy.

There is a simple way to implement this function.

1. In the place where New, this method should be covered by a subclass.

2. In Test, override this method and return to Mock Object

3, you can test it.

转载请注明原文地址:https://www.9cbs.com/read-66211.html

New Post(0)