There are ways to connect to the `rostest`'s [[roscore]], which is restarted for each test in order to have a clean test fixture. == Indigo and later == By default rostest uses a random port so many `rostest`s can be run in parallel. === Re-use an already-running master === This behavior can be overridden with the reuse-master flag, and then the standard ROS_MASTER_URI will be used for the test. Start a roscore in another terminal, then: {{{ rostest --reuse-master foo_package foo.test }}} See also [[http://answers.ros.org/question/208361/port-to-connect-to-rostest-rosmaster-after-indigo/|this question thread]] and [[https://github.com/ros/ros_comm/pull/637|this pull request]]. === Connect to rostest's master === Bit hacky but it's possible. While `rostest` is running, run a command something like: {{{ grep -r "Registering with master node" ~/.ros/log/latest }}} This will return the master's URL with the port number. Then update your `ROS_MASTER_URI`: {{{ export ROS_MASTER_URI=http://localhost:%PORTNUMBER_YOUFOUND% }}} NOTE: Again, port number differs per every `rostest` run. When you're running `rostest` by integrated way (e.g. [[http://docs.ros.org/indigo/api/catkin/html/howto/format2/run_tests.html|catkin_make run_tests]]), multiple `rostest`s can be included and running at the same time, so that you might see multiple different port numbers in the `grep` result above. Choose the one you want to connect to carefully. == Pre-Indigo == In hydro and earlier `rostest` uses port 22422 to not conflict with any running [[roscore]] instance. Thus, to connect to the `rostest` [[Master]] from another terminal you must first: {{{ export ROS_MASTER_URI=http://localhost:22422 }}} == Tests without rostest == A different approach to connecting to the volatile [[rostest]] roscore is to run your test file using [[roslaunch]]. The portions of the test file will not run, so you then manually launch your test node to observe its behavior. For example if the foo.test consisted of the following: {{{ }}} Launch the node and the test separately: {{{ roslaunch foo_package foo.test }}} Then in another terminal: {{{ rosrun foo_package foo_node-test }}}