Closed hitzhangjie closed 3 years ago
Let alone whether it is technically feasible. If you define an interface, then at least one class in the system will implement this interface, otherwise, what do you define this interface for? Now that there is an implementation class, we will not need to create that dynamically, right? The implementation class can be reused directly in the test.
Yes.
Could we mock interface variable directly instead of create a struct implementing interface methods?
If technically we can, how difficult is it? What should we do ?
I think we can dynamiclly create a struct and add methods to it, and use this struct as an instance of type of interface implemention.