I am developing a library for serial communications with an FPGA via RS-422 port. This library is part of a bigger project.
I know I can test some parts of it, as the message generation. You set the inputs, and you can test if the array of bytes match the expected one. But, what if I wanted to make a more general test, how could I generate unit tests for it? do I have to write a simulator of the FPGA behaviour? is it possible to test the library in isolation?
I would say that testing with an emulator or mock is going to let you exercise your code paths much more easily than prodding the real thing.
Ideally one uses something pre-existing. Otherwise it may not be a small amount of effort to build the emulation. However, if you don’t understand the protocol well enough to emulate it then you surely can’t communicate with it 🙂