Ask Your Question
4

rostest code coverage

asked 2014-07-01 11:56:42 -0600

mbforbes gravatar image

updated 2014-07-02 11:30:48 -0600

130s gravatar image

I'm writing tests in python, and I'm hoping to use rostest and get a coverage report of my code.

I notice on the unittest page it says that this can be done by adding a coverage_packages argument to rostest.rosrun. Doing so gives me the following error in my test output:

TypeError: rosrun() got an unexpected keyword argument 'coverage_packages'

If I omit this argument and the tests actually run, no coverage report is generated anywhere I can see (neither log directory nor project directory).

I see that rosunit even has helper scripts for generating these... is this all deprecated and unsupported? Or is there a way to get code coverage reports?

Basic info:

  • Ubuntu 12.04
  • ROS Groovy
  • rosbuild
  • python
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-07-02 14:24:12 -0600

130s gravatar image

Looking at the code, it seems that rostest.rosrun does not take 5th argument coverage_package.

def rosrun(package, test_name, test, sysargs=None):

Instead, unitrun (seems deprecated) takes it (code).

def unitrun(package, test_name, test, sysargs=None, coverage_packages=None):
    :
    @param coverage_packages: list of Python package to compute coverage results for. Defaults to package
    @type coverage_packages: [str]

It would be beneficial to the community if you could test this method and provide how it goes.

Btw, with coverage_packages I think you need to give actual name of the packages; what your error message indicates is you gave coverage_packages string.

edit flag offensive delete link more

Comments

1

Thanks Isaac for looking into this! After seeing `unitrun` is deprecated, I decided to just add code coverage myself, because it's quite easy. Here's an example for anyone wondering: http://git.io/__B2wg (Also thanks for editing my question---my reputation wasn't high enough to post links :-)

mbforbes gravatar imagembforbes ( 2014-07-03 16:11:05 -0600 )edit
2

answered 2015-01-13 03:14:12 -0600

updated 2015-01-13 03:14:27 -0600

Looking the rosrun code it seems that it actually does support coverage through the sysargs parameter: sysargs=--cov

edit flag offensive delete link more

Comments

2

Looks like you're right. This needs to be documented.

130s gravatar image130s ( 2015-01-13 09:46:32 -0600 )edit

Indeed, it would be great to have it documented. Actually, after posting the question I've tried to get some coverage of my code without success. Do you know where we can open the issue? I'm not sure wether to report this to the wiki or to rosrun's repo.

Victor Gonzalez-Pacheco gravatar imageVictor Gonzalez-Pacheco ( 2015-01-17 09:02:37 -0600 )edit

Opening an issue on ros_comm where rostest resides is a good start I think.

130s gravatar image130s ( 2015-01-17 11:04:37 -0600 )edit
1

Opened! See ros_comm#553

Victor Gonzalez-Pacheco gravatar imageVictor Gonzalez-Pacheco ( 2015-01-20 16:50:06 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

4 followers

Stats

Asked: 2014-07-01 11:56:42 -0600

Seen: 1,618 times

Last updated: Jul 02 '14