By dave | November 15, 2017

Troubleshooting IO issues using LoggingIoAbstraction

Within the MockIoAbstraction.h header there is an implementation of BasicIoAbstraction that delegates through a logging layer. If you are having difficulty determining what your code is sending and receiving, this could be useful. You simply introduce the logging abstraction between your regular abstraction and the device you’re having trouble with. For example:

LoggingIoAbstraction loggingAbstraction(internalDigitalIo());

ComponentThatNeedsDebugging debugging(internalDigitalIo());
ComponentThatNeedsDebugging debugging(asIoRef(loggingAbstraction));

Mock objects for use with Unit testing

This library itself is quite well tested using our simple test facilities, and further it makes unit testing your code easier. There is a MockIoAbstraction that provides very easy support for mocking out an IoAbstraction. You just provide how many sync() calls to store in the internal buffer:

MockedIoAbstraction mockIo(numberOfCycles = 6);

There is a simulated version of the EepromAbstraction, this uses a small amount of memory to store the EEPROM state, to avoid writes to ROM during testing.

MockEepromAbstraction myRom(romSize = 128);

There is no need for a mock task manager, just use the regular instance, it has accessors to get hold of tasks if needed. Be sure to call reset() after each test that interacts with it.

These Mock interfaces are fully documented in the reference docs.

Go back to the IoAbstraction page

Other pages within this category

comments powered by Disqus

This site uses cookies to analyse traffic, and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.

Send a message
X

Please use the forum for help with UI & libraries.

This message will be securely transmitted to our servers.