ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
ROS is agnostic to which unit testing framework you use, but most folks use gtest for C++ and unittest for Python. For Python, nosetest (an abstraction on top of unittest) is often used as well.
Integration tests are actually just an extension of unit testing in ROS and is handled through rostest. rostest is simply a wrapper around roslaunch. You can add <test> tags anywhere inside a standard ROS launch file to add additional nodes that are launched specifically for testing. roslaunch ignores these tags, but rostest does not. If you use rostest, it will bring up all the regular nodes (tag <node>) plus the test nodes (tag <test>) specified in the launch file. Usually launch files meant for testing have the .test extension.
Within your test nodes, you simply use a unit testing framework to report to rostest the results of the test. If you're in C++, it's easiest to use gtest...in Python use unitest. rostest then intercepts the output of the test nodes when you exit and compiles it into a single integration test report in XML (I believe it uses the JUnit encoding for this).
This is where the examples are for Python. They're mostly correct but a little dated and I think there's a mistake at the end -- I don't have the chance to fix that now but will make a note too. http://wiki.ros.org/unittest#ROS-Node-Level_Integration_Tests
In general, for both Python unit and integration tests you want to do the following: 1) Create a class that subclasses from unittest.TestCase 2) Have a bunch of methods with the prefix "test_". Each represents a test case 3) Implement your tests in these methods using the assert*() calls (e.g.self.assertTrue) 4) Integration tests are the same except you create a ROS node handle within the test case and start publishing/subscribing. You perform checks in the exact same way as you do with unittest
I can't find any good examples right now, maybe somebody can jump in and comment.
2 | No.2 Revision |
ROS is agnostic to which unit testing framework you use, but most folks use gtest for C++ and unittest for Python. For Python, nosetest (an abstraction on top of unittest) is often used as well.
Integration tests are actually just an extension of unit testing in ROS and is handled through rostest. rostest is simply a wrapper around roslaunch. You can add <test> tags anywhere inside a standard ROS launch file to add additional nodes that are launched specifically for testing. roslaunch ignores these tags, but rostest does not. If you use rostest, it will bring up all the regular nodes (tag <node>) plus the test nodes (tag <test>) specified in the launch file. Usually launch files meant for testing have the .test extension.
Within your test nodes, you simply use a unit testing framework to report to rostest the results of the test. If you're in C++, it's easiest to use gtest...in Python use unitest. rostest then intercepts the output of the test nodes when you exit and compiles it into a single integration test report in XML (I believe it uses the JUnit encoding for this).
This is where the examples are for Python. They're mostly correct but a little dated and I think there's a mistake at the end -- I don't have the chance to fix that now but will make a note too.
to.
http://wiki.ros.org/unittest#ROS-Node-Level_Integration_Tests
In general, for both Python unit and integration tests you want to do the following: 1) Create a class that subclasses from unittest.TestCase 2) Have a bunch of methods with the prefix "test_". Each represents a test case 3) Implement your tests in these methods using the assert*() calls (e.g.self.assertTrue) 4) Integration tests are the same except you create a ROS node handle within the test case and start publishing/subscribing. You perform checks in the exact same way as you do with unittest
I can't find any good examples right now, maybe somebody can jump in and comment.
3 | No.3 Revision |
ROS is agnostic to which unit testing framework you use, but most folks use gtest for C++ and unittest for Python. For Python, nosetest (an abstraction on top of unittest) is often used as well.
Integration tests are actually just an extension of unit testing in ROS and is handled through rostest. rostest is simply a wrapper around roslaunch. You can add <test> tags anywhere inside a standard ROS launch file to add additional nodes that are launched specifically for testing. roslaunch ignores these tags, but rostest does not. If you use rostest, it will bring up all the regular nodes (tag <node>) plus the test nodes (tag <test>) specified in the launch file. Usually launch files meant for testing have the .test extension.
Within your test nodes, you simply use a unit testing framework to report to rostest the results of the test. If you're in C++, it's easiest to use gtest...in Python use unitest. rostest then intercepts the output of the test nodes when you exit and compiles it into a single integration test report in XML (I believe it uses the JUnit encoding for this).
This is where the examples are for Python. They're mostly correct but a little dated and I think there's a mistake at the end -- I don't have the chance to fix that now but will make a note to. http://wiki.ros.org/unittest#ROS-Node-Level_Integration_Tests
In general, for both Python unit and integration tests you want to do the following:
1) 1. Create a class that subclasses from unittest.TestCase
2) 2. Have a bunch of methods with the prefix "test_". Each represents a test case
3) 3. Implement your tests in these methods using the assert*() calls (e.g.self.assertTrue)
4) 4. Integration tests are the same except you create a ROS node handle within the test case and start publishing/subscribing. You perform checks in the exact same way as you do with unittestunittest
5. For integration tests, you also want to add a "add_rostest" to your CMakeLists.txt file.
6. catkin_make run_tests in your catkin workspace
I can't find any good examples right now, maybe somebody can jump in and comment.
4 | No.4 Revision |
ROS is agnostic to which unit testing framework you use, but most folks use gtest for C++ and unittest for Python. For Python, nosetest (an abstraction on top of unittest) is often used as well.
Integration tests are actually just an extension of unit testing in ROS and is handled through rostest. rostest is simply a wrapper around roslaunch. You can add <test> tags anywhere inside a standard ROS launch file to add additional nodes that are launched specifically for testing. roslaunch ignores these tags, but rostest does not. If you use rostest, it will bring up all the regular nodes (tag <node>) plus the test nodes (tag <test>) specified in the launch file. Usually launch files meant for testing have the .test extension.
Within your test nodes, you simply use a unit testing framework to report to rostest the results of the test. If you're in C++, it's easiest to use gtest...in Python use unitest. rostest then intercepts the output of the test nodes when you exit and compiles it into a single integration test report in XML (I believe it uses the JUnit encoding for this).
This is where the examples are for Python. They're mostly correct but a little dated and I think there's a mistake at the end -- I don't have the chance to fix that now but will make a note to. http://wiki.ros.org/unittest#ROS-Node-Level_Integration_Tests
In general, for both Python unit and integration tests you want to do the following:
1. Create a class that subclasses from unittest.TestCase
2. Have a bunch of methods with the prefix "test_". Each represents a test case
3. Implement your tests in these methods using the assert*() calls (e.g.self.assertTrue)
4. Integration tests are the same except you create a ROS node handle within the test case and start publishing/subscribing. You perform checks in the exact same way as you do with unittest
5. For integration tests, you also want to add a "add_rostest" to your CMakeLists.txt file.
6. catkin_make run_tests in your catkin workspace
I can't find any good examples right now, maybe somebody can jump in and comment.
5 | No.5 Revision |
ROS is agnostic to which unit testing framework you use, but most folks use gtest for C++ and unittest for Python. For Python, nosetest (an abstraction on top of unittest) is often used as well.
Integration tests are actually just an extension of unit testing in ROS and is handled through rostest. rostest is simply a wrapper around roslaunch. You can add <test> tags anywhere inside a standard ROS launch file to add additional nodes that are launched specifically for testing. roslaunch ignores these tags, but rostest does not. If you use rostest, it will bring up all the regular nodes (tag <node>) plus the test nodes (tag <test>) specified in the launch file. Usually launch files meant for testing have the .test extension.
Within your test nodes, you simply use a unit testing framework to report to rostest the results of the test. If you're in C++, it's easiest to use gtest...in Python use unitest. rostest then intercepts the output of the test nodes when you exit and compiles it into a single integration test report in XML (I believe it uses the JUnit encoding for this).
This is where the examples are for Python. They're mostly correct but a little dated and I think there's a mistake at the end -- I don't have the chance to fix that now but will make a note to. http://wiki.ros.org/unittest#ROS-Node-Level_Integration_Tests
In general, for both Python unit and integration tests you want to do the following:
1. following:
I can't find any good examples right now, maybe somebody can jump in and comment.