Skip to content

Commit cca3117

Browse files
authored
Make UrDriver tests run without ctest (#270)
As `ctest` runs each test individually, an error with test initialization introduced earlier didn't show. This change makes sure that running all tests consecutively with initializing the test suite only once works correctly.
1 parent d8e1ff9 commit cca3117

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tests/test_ur_driver.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,17 @@ class UrDriverTest : public ::testing::Test
6262

6363
void SetUp()
6464
{
65-
ASSERT_TRUE(g_my_robot->isHealthy());
65+
if (!g_my_robot->isHealthy())
66+
{
67+
ASSERT_TRUE(g_my_robot->resendRobotProgram());
68+
ASSERT_TRUE(g_my_robot->waitForProgramRunning(500));
69+
}
70+
}
71+
72+
void TearDown()
73+
{
74+
g_my_robot->ur_driver_->stopControl();
75+
g_my_robot->waitForProgramNotRunning(1000);
6676
}
6777
};
6878

@@ -224,13 +234,16 @@ TEST_F(UrDriverTest, send_robot_program_retry_on_failure)
224234
{
225235
// Check that sendRobotProgram is robust to the secondary stream being disconnected. This is what happens when
226236
// switching from Remote to Local and back to Remote mode for example.
227-
g_my_robot->ur_driver_->secondary_stream_->close();
228237

229-
std::this_thread::sleep_for(std::chrono::milliseconds(100));
238+
// To be able to re-send the robot program we'll have to make sure it isn't running
239+
g_my_robot->ur_driver_->stopControl();
240+
g_my_robot->waitForProgramNotRunning();
241+
242+
g_my_robot->ur_driver_->secondary_stream_->close();
230243

231244
EXPECT_TRUE(g_my_robot->resendRobotProgram());
232245

233-
EXPECT_TRUE(g_my_robot->waitForProgramRunning());
246+
EXPECT_TRUE(g_my_robot->waitForProgramRunning(1000));
234247
}
235248

236249
TEST_F(UrDriverTest, reset_rtde_client)

0 commit comments

Comments
 (0)