-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We need mock LCM interfaces for unit testing #3546
Comments
Current PostI'm trying to understand how #3494 could be modified to address this issue. Here's my first guess:
Is the above what's meant by "use a mock and dependency injection"? Original PostI'm trying to understand how #3494 could be modified to address this issue. Here's my first guess:
Is the above what's meant by "use a mock and dependency injection"? |
Nope. The basic premise of mocking is that (essentially) no Drake code ever says |
@jwnimmer-tri: I'm having trouble figuring out what's the difference between your description and my proposal. Is the only difference the name |
Ah yes. The name confused me -- they are indeed similar. It's important to use Also typically the |
Got it. Thanks. I'll go ahead and assign this to myself since I plan on implementing it after #3494 is merged. |
I'm going to start work on this now. |
Must the mock LCM instance be so decoupled from LCM that it should be usable even if LCM is not present on the local machine? I ask because the lcm::LCM::subscribe() API includes things like lcm::ReceiveBuffer and lcm::Subscription that will be undefined if LCM is not present. Do I need to mock up all of these classes as well? |
I suspect any reasonable testing with an LCM mock will be still using non-mocked Encode and Decode methods, so LCM-as-a-build-dependency is likely fine (though perhaps nice to remove, if we can). However, perhaps you can offline explain your mock design, because I am surprised that such types would still be needed in mock-land. |
From F2F meeting with @jwnimmer-tri, the mock
Note that |
WIP branch is here: https://github.com/liangfok/drake/tree/feature/lcm_mock. I have the basic framework completed and the real LCM-encapsulating class implemented and unit tested. I still need to implement the mock version and to integrate the framework with all of the System 2.0 systems that use LCM. |
🎉 very nice! thanks again! |
You're welcome! |
Right now, there are two prevailing approaches for unit-testing code that sends or receives LCM:
A better solution would be to use a mock and dependency injection.
The text was updated successfully, but these errors were encountered: