How to do TDD with hardware

2019-02-01 12:38发布

All the projects I work interface to a piece of hardware and this is often the main purpose of the software. Are there any effective ways I can apply TDD to the code that works with the hardware?

Update: Sorry for not being clearer with my question.

The hardware I use is a frame grabber that capture images from a camera. I then process these images, display them and save them to disk. I can simulate all the processing that takes place after the images are captured by using previously captured images that are stored on disk.

But it's the actual interaction with the hardware that I want to test. For instance does my software cope correctly when there isn't a camera attached, does it properly start and stop grabbing etc. But this is so tied into the hardware I don't know how to test it when the hardware isn't present or if I should even be trying to do this?

2nd Update: I'm also looking for some concrete examples of exactly how people have dealt this situation.

标签: tdd hardware
7条回答
闹够了就滚
2楼-- · 2019-02-01 13:35

If you have a simulator, you could write tests against the simulator and run these tests against the hardware.

It's hard to answer the questions with so little detail :-)

查看更多
登录 后发表回答