Skip to content

Conversation

@jacobperron
Copy link

Also fixed what I think was a bug in ca0a225.

This change introduces a new dependency mockito, which I think is super useful for writing tests with mock objects. I've proposed a rosdep rule for it in ros/rosdistro#26308.
Note, if we want to eventually support Windows, we'll have to investigate installing the jars for mockito and its dependencies (perhaps like how we handle JUnit).

@ivanpauno
I first wanted to get your thoughts on introducing this dependency before putting more effort into supporting Windows and resolving the TODO in the CMakeLists.txt.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron jacobperron self-assigned this Aug 25, 2020
@jacobperron jacobperron requested a review from ivanpauno August 25, 2020 21:22
- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Author

Note, CI is dependent on the rosdistro PR. Alternatively, I can implement what I proposed for Windows and conditionally download and install the mockito jars if a sufficient version is not already installed on the system.

@ivanpauno
Copy link
Collaborator

I first wanted to get your thoughts on introducing this dependency before putting more effort into supporting Windows and resolving the TODO in the CMakeLists.txt.

The new dependency looks great to me, Mockito seems to be very powerful.

Note, if we want to eventually support Windows, we'll have to investigate installing the jars for mockito and its dependencies (perhaps like how we handle JUnit).

Maybe we should have a "vendor package" for those extra jars.
That vendor package could set MOCKITO_JARS to the correct thing when find packaged (I'm not quite sure of cmake variable naming conventions for java projects).

@jacobperron
Copy link
Author

Sounds good. I'll create a vendor package and refactor this PR to use it. I'm not sure about naming conventions either (I don't think Java is typically built with CMake), but I'll try to be consistent with what is already in the ros2-java project.

@jacobperron
Copy link
Author

I've created a vendor package in ros2-java/mockito_vendor#1, I'll update this PR to use it

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron jacobperron requested review from ivanpauno and removed request for ivanpauno August 28, 2020 23:55
Copy link
Collaborator

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Author

I'm not sure why CI is failing... mockito_vendor appears to be cloned to the workspace, but it is not seen by rosdep or colcon 🤔

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Author

Looks like it was a bug with the Action action-ros-ci (ros-tooling/action-ros-ci#342).

I've made a patch to the action and updated the workflow here to see if it resolves the issue 35e926e.

@ivanpauno
Copy link
Collaborator

Looks like it was a bug with the Action action-ros-ci (ros-tooling/action-ros-ci#342).

That's a fun bug 😂

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron jacobperron force-pushed the jacob/time_source_tests branch from 801bc3c to c4e8ed7 Compare September 17, 2020 16:50
with:
required-ros-distributions: foxy
- uses: ros-tooling/action-ros-ci@0.0.19
- uses: ros-tooling/action-ros-ci@master
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobperron jacobperron merged commit 00ab08b into feature/ros_time Sep 17, 2020
@jacobperron jacobperron deleted the jacob/time_source_tests branch September 17, 2020 18:10
jacobperron added a commit that referenced this pull request Sep 18, 2020
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit that referenced this pull request Sep 18, 2020
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit that referenced this pull request Sep 18, 2020
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit that referenced this pull request Sep 18, 2020
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
ivanpauno pushed a commit that referenced this pull request May 17, 2021
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit to ros2-java/ros2_java that referenced this pull request May 13, 2022
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit to ros2-java/ros2_java that referenced this pull request May 13, 2022
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit to ros2-java/ros2_java that referenced this pull request May 13, 2022
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
jacobperron added a commit to ros2-java/ros2_java that referenced this pull request May 17, 2022
* Notify clocks when use_sim_time parameter changes

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add unit tests for TimeSource class

Introduce Mockito dependency to help with creating mock objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add test dependency on libmockito-java

Depends on ros/rosdistro#26308

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Minor refactor

- Switch to using @mock annotation.
- Cleanup

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Depend on mockito_vendor package

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add mockito_vendor to repos file

This should make CI green.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Update branch for mockito_vendor

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
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

Successfully merging this pull request may close these issues.

3 participants