[ROS in 5 mins] 055 – Four different ways of testing your ROS python code
Welcome to this “ROS In 5 Minutes” videos series.
In today’s videos we are going to learn 4 different ways of testing your ROS code written in python.
But before we start, if you want to Learn ROS Fast, remember to take one of the following courses:
In order to create our package we have used the following commands:
mkdir ~/catkin_ws/src -p
catkin_create_pkg tutorial rospy
chmod +x test_code.py
The content of our test_code.py file is:
#! /usr/bin/env python
if __name__ == “__main__”:
rostest.rosrun(‘tutorial’, ‘test_code’, MyTestCase)
The first way of executing it is by calling it directly:
The second way is using a .test file:
After filling that file we call it with:
rostest tutorial test_code.test
The 3rd way of executing is by adding the line below to our CMakeLists.txt file:
And the 4th way is by adding the lines below to our CMakeLists.txt file (remove to remove the line added on the 3rd way, otherwise
your test will be executed twice, wasting time):
That is all for today.
Whether you like the video or not, please leave a comment on the comments section below,
so that we can interact and learn from each other.