Skip to content
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

Unit Testing Nodelets #36

Open
progtologist opened this issue Dec 31, 2015 · 2 comments
Open

Unit Testing Nodelets #36

progtologist opened this issue Dec 31, 2015 · 2 comments

Comments

@progtologist
Copy link

While using nodelets, I discovered that the API does not provide a method for returning a nodelet object from the nodelet loader. Although such a method is not the proposed way to use nodelets, it would be very useful for unit testing nodelets with google tests.

Right now, the only way to do this is to use the

nodelet::Loader::Loader(const boost::function< boost::shared_ptr< Nodelet >(const std::string &lookup_name)> &  create_instance)

method to instantiate the object, and to share that pointer with the unit tests. However it would be more elegant to be able to get the object (pointer) using a loader method.

@daniel-dsouza
Copy link

do you by any chance still have an example of this?

@progtologist
Copy link
Author

Unfortunately I don't have access to that code anymore.
If I remember correctly though, you must create a function that creates nodelets and create a loader providing that function.
In your function you can have a std::map or even an std::vector that, while instantiating the nodelet, also adds it to that structure.
From your app, you use that new loader to instantiate the nodelet, and you can access that structure to get your instance at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants