-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rostest example #71
Rostest example #71
Conversation
Basics have been written, need to change some CMakeList entries: Still need to add a blurb about where results are located. |
@@ -108,11 +109,19 @@ some_ros_package | |||
| | <b>my_node.cpp</b> | |||
</pre> | |||
|
|||
## Launch files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬 can't believe I didn't put a section on this in the readme..... good idea! 😃
Also, in the example given in |
In response to above (for documentation of discussion sake): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do a full review, just happened to spot these while I was using your PR as reference for how to use setup / test fixtures
} | ||
}; | ||
|
||
TEST_F(MyClassTest, MyNodeTest){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that perhaps we should name the test class MyNodeTest
, with the second name being reserved to indicate very briefly the functionality you're trying to test.
|
||
/** | ||
* This is the helper class which will publish and subscribe messages which will test the node being instantiated | ||
* It contains on the minimum: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"at the minimum" might be a better way of phrasing it
README.md
Outdated
@@ -94,7 +95,8 @@ some_ros_package | |||
| | <b>MyNode.h</b> | |||
| | |||
└───test | |||
| | <b>my-node-test.cpp</b> | |||
| | <b>my_node_test.cpp</b> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we've decided to only change the naming convention to use underscores for ros-tests, this should still be my-node-test.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, my_node_rostest.cpp
should be in this hierarchy
README.md
Outdated
## Testing | ||
- GTest is our primary testing tool at the moment. The ROS wiki has a quick intro to it [here](http://wiki.ros.org/gtest), and we also strongly recommend you read Google's introduction to it [here] (https://github.com/google/googletest/blob/master/googletest/docs/Primer.md), then setup and write a few example tests before you start using it with ROS. | ||
- Once you've setup your tests in ROS, run `catkin_make run_tests` to run them | ||
- To run the tests for a specific package, run `catkin_make run_tests_MY_PACKAGE_NAME` | ||
|
||
### Rostest | ||
- For tests which require more than one active node, i.e. integrated testing, the rostest framework provides a way to launch your test alongside all the nodes it requires. This is an extension on roslaunch enabling it to run test nodes. Special test nodes are nested within a `<test></test>` tag. This also needs a special entry under CMakelists as shown in the sample package. See more details [here](http://wiki.ros.org/rostest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This is an extension..." has an extra space
|
||
// spinOnce allows ros to actually process your callbacks | ||
// for the curious: | ||
// http://answers.ros.org/question/11887/significance-of-rosspinonce/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicky thing, but lines 60 & 61 can be one line
messageOutput = msg->data.c_str(); | ||
} | ||
|
||
std::string getMessage(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this function. I believe test fixtures have access to protected variables. Might just be cleaner to make it a direct access. (that being said, that's kind of icky) or just making the messageOutput
private.
ros::NodeHandle nh_; | ||
std::string messageOutput; | ||
ros::Publisher testPublisher; | ||
ros::Subscriber testSubscriber; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost last thing - promise. Variables should be written_like_this
} | ||
}; | ||
|
||
TEST_F(MyNodeTest, ExclamationMarkAppend){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just going off how tests have been named so far, this should be exclamationMarkAppendTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, thinking about it some more, that convention is pretty stupid. There's really no reason to have the word "test" on the end of each test, so exclamationMarkAppend
would be fine (note changes to capitalization)
I keep coming back to approve it and seeing stuff... sorry... 😆 |
What could possibly go wrong? |
Closes #66, closes #67