Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Remote Unit Testing

I am working on a project where development and target environments are quite different. Target environment has different peripherals, IO cards etc and my project makes use of these peripherals very often. Whereas my development environment is lacking these peripherals. Therefore unit testing on my development box is useless most of the time.

I am using Eclipse CDT and remote debugging plugin and I am debugging over the network, I want to make better use of unit testing and based on the above facts I am wondering what my best option is. So far I've been writing test programs for every new feature that I add and I test it with remote debugging, it seems like an inefficient way of testing since it takes a lot of time to write tests and perform tests.

Any suggestions?

like image 266
erin c Avatar asked Mar 28 '26 00:03

erin c


1 Answers

In this environment it's quite difficult to do without expensive tools. I think the best solution is to write test programs as you have done, but combine them all into a single program you can launch once and have it run all the tests without manual intervention. I use the Boost Test library for this.

The real key is figuring out how to write your tests so that they can self-check. You don't want your test code to do something that requires you to manually verify the result. This may mean having a second program running elsewhere which monitors the output from the target environment's peripherals and complains if it doesn't match what the test code is supposed to be sending. Tests are after all meant to verify correctness, not just prove that something doesn't crash.

And of course tests need to be written intelligently too. If you are designing a communication protocol and a network driver, you might need remote test code to confirm the correct bytes are being sent out of the network port, but you don't need this to test your communication protocol. The test code can create a virtual network device and run the protocol tests over that (which could even run in your dev environment), so you should be able to test everything except hardware drivers locally in the development environment.

like image 140
Malvineous Avatar answered Mar 31 '26 03:03

Malvineous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!