Browse Source

Test format

pull/35/head
hello-adamc 3 years ago
parent
commit
286d4d97a8
6 changed files with 45 additions and 1 deletions
  1. +5
    -0
      stretch_core/CMakeLists.txt
  2. +9
    -0
      stretch_core/nodes/tests/test_stretch_driver.py
  3. +1
    -1
      stretch_core/package.xml
  4. +0
    -0
     
  5. +26
    -0
      stretch_core/tests/pytest_runner.py
  6. +4
    -0
      stretch_core/tests/stretch_driver_test.test

+ 5
- 0
stretch_core/CMakeLists.txt View File

@ -204,3 +204,8 @@ include_directories(
## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
add_rostest(tests/stretch_driver_test.test)
endif()

+ 9
- 0
stretch_core/nodes/tests/test_stretch_driver.py View File

@ -0,0 +1,9 @@
import pytest
def test_hello_works():
assert True
def test_hello_does_not_work():
assert False

+ 1
- 1
stretch_core/package.xml View File

@ -82,7 +82,7 @@
<exec_depend>std_srvs</exec_depend>
<exec_depend>tf</exec_depend>
<exec_depend>tf2</exec_depend>
<test_depend>rostest</test_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>

+ 0
- 0
View File


+ 26
- 0
stretch_core/tests/pytest_runner.py View File

@ -0,0 +1,26 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import rospy
import pytest
def get_output_file():
for arg in sys.argv:
if arg.startswith('--gtest_output'):
return arg.split('=xml:')[1]
raise RuntimeError('No output file has been passed')
if __name__ == '__main__':
output_file = get_output_file()
test_module = rospy.get_param('test_module')
runner_path = os.path.dirname(os.path.realpath(__file__))
module_path = os.path.join(runner_path, test_module)
sys.exit(
pytest.main([module_path, '--junitxml={}'.format(output_file)])
)

+ 4
- 0
stretch_core/tests/stretch_driver_test.test View File

@ -0,0 +1,4 @@
<launch>
<param name = "test_module" value = "../nodes"/>
<test test-name = "test_stretch_driver" pkg = "stretch_core" type = "pytest_runner.py"/>
</launch>

Loading…
Cancel
Save