While the definition of a unit test only checks the logic within the context of a specific method. My thought for FRC is that there are a number of times I want to do more of an integration test where I need to make sure some simulated hardware actually reacts as I would expect (i.e. the motor controller’s output value changes and stay set, sensors respond with a simulated response). This is most critical in situations with feedback control (i.e. PID) where having some simplified simulated hardware in the loop becomes exceedingly useful.
In my thoughts the ‘holy grail’ of testing would include a simulated hardware definition that would allow a motor and sensor (encoder) to be connected in a mixed-mode simulation. Then a requested speed/power change on the motor controller would be reflected on the sensor after a specified simulated time interval. But this will be much more involved then a ‘unit test’.
I know that WPILIB now has simulation capabilities and improved unit test functionality, however is there any way to handle simulated hardware from within WPILIB?
I would really like to see code from someone (a link to github would be more than sufficient) that shows a unit test with a mocked-up motor controller connected that can keep state to enable feedback testing.