我想通过调用包根目录中的catkin_make test
在ros环境中通过rostest触发python单元测试。在
ros的版本是python2.7.3的hydro版本
在official instructions中,我编写了一个测试,当使用命令rostest jenkins_test_repro testAll.test
和相关的here调用它时,它工作得很好。在
在直接执行脚本时也能很好地工作。。。在
测试输出:
/home/USER/VirtEnvPython/bin/python /home/USER/sandbox/metric_tester/src/jenkins_test_repro/scripts/TestMetricStarter.py
[ROSUNIT] Outputting test results to /home/USER/.ros/test_results/jenkins_test_repro/rosunit-MetricStarter.xml
test_server_feedback ... ok
test_true ... ok
-------------------------------------------------------------
SUMMARY:
* RESULT: SUCCESS
* TESTS: 2
* ERRORS: 0 []
* FAILURES: 0 []
测试文件:
^{pr2}$“启动”-文件:
<launch>
<test test-name="MetricStarter" pkg="jenkins_test_repro" type="TestMetricStarter.py" />
</launch>
为了通过catkin_make test
调用测试,我需要在CMakeLists.txt文件.
我想出了三种方法来做到这一点,但对我来说,我还不清楚我真正需要做什么。对于所有的方式,我做了一个干净的构建(删除构建/开发和重新构建catkin工作区)
因为rostest
的使用以及与工作命令行执行的类比
add_rostest(test/testAll.test)
但测试似乎没有执行:
Running tests...
Test project /home/USER/sandbox/metric_tester/build
Start 1: _ctest_jenkins_test_repro_rostest_test_testAll.test
1/1 Test #1: _ctest_jenkins_test_repro_rostest_test_testAll.test ... Passed 1.64 sec
100% tests passed, 0 tests failed out of 1
Total Test time (real) = 1.65 sec
catkin_make test 4.58s user 0.54s system 79% cpu 6.404 total
我也试过了
add_rostest(scripts/TestMetricStarter.py)
导致以下错误
Running tests...
Test project /home/USER/sandbox/metric_tester/build
Start 1: _ctest_jenkins_test_repro_rostest_scripts_TestMetricStarter.py
1/1 Test #1: _ctest_jenkins_test_repro_rostest_scripts_TestMetricStarter.py ...***Failed 0.46 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.47 sec
The following tests FAILED:
1 - _ctest_jenkins_test_repro_rostest_scripts_TestMetricStarter.py (Failed)
Errors while running CTest
make: *** [test] Error 8
Invoking "make" failed
刚试过,但这和罗斯特有关
add_rostest_gtest(jenkins_test_repro test/testAll.test scripts/TestMetricStarter.py)
但由于输出和请求的链接器语言,似乎是c/c++的东西
CMake Error: CMake can not determine linker language for target:jenkins_test_repro
CMake Error: Cannot determine link language for target "jenkins_test_repro".
-- Generating done
-- Build files have been written to: /home/USER/sandbox/metric_tester/build
make: *** [cmake_check_build_system] Error 1
在official guide中是运行tests as part of ^{
这会导致与第一种方式类似的行为
catkin_add_nosetests(test/testAll.test)
与add_rostest(scripts/TestMetricStarter.py)
相同
catkin_add_nosetests(scripts/TestMetricStarter.py)
与add_rostest(test/testAll.test)
所以仍然有一个问题,我必须如何在CMakeLists.txt文件... 对我来说,对于用python编写的单元测试,如何做到这一点还不清楚。对于c/cpp,有一些方法是可行的,但是对于python呢?在
由于构建场上的工具链,如果有一种方法可以用catkin_make test
触发测试,那就更好了。此问题不要求其他绕过CMake的方法。在
如果需要更多信息,只需问:)。我希望有人能帮助或提示正确的解决办法。在
编辑:我在http://answers.ros.org上发布了同样的问题,因为我认为这仍然是一个非常具体的问题。如果有人有类似的问题,我会把它贴在这里。在
如前所述,here解决方案起作用。目前还不清楚是什么真正改变了,因为
add_rostest(test/testAll.test)
在之前被测试过(第一种方法)。。。在只是在CMakeLists.txt文件公司名称:
相关问题 更多 >
编程相关推荐