Is a mocking framework a good idea for working with several physical devices, and mocking them ?
The main goal of my compagnie is to interface our software with several brand of theater projector( barco, sony… ) , sound processor, IO controler ( barionet, wago ).
Sometime the vendor give an API for the communication, sometime it’s done with socket, sometimes it’s realy realy “vendor specific”
Until now, here is our methodology:
We are looking for a consistent way of testing our code, without the real devices. And without wasting time to write emulator.
Edit :
We talk to 4 type of devices :
Heck yeah. I think that this is a perfect place for a mocking framework. Just create an interface layer that separates the hardware (or hardware api) from the code that controls it… IProjector, ISoundProcessor, etc.
Once you have separated the hardware from the software and you are not directly dependent upon the hardware, you can use a mocking framework to write mocks or stubs that pretend like IProjector is real hardware. If you know that HardwareX responds to a certain method with a particular value, capture it and return it with your mocking framework.
Note that a mocking framework, per se, is not required. You could always create a fake like you are suggesting, but sometimes that fake gets too complicated because they are used by too many tests, and you get bugs in your fake. In that case, the mocking framework comes in and you can define only the behavior that you need in that particular test…