Can GoogleTest tests run against actual hardware instead of mock objects?

1,281 views
Skip to first unread message

Patricia LaRue

unread,
May 15, 2015, 4:02:45 PM5/15/15
to googletes...@googlegroups.com
We are attempting to use GoogleTest to test C++ linux software and embedded software.  My manager wants to know if we can run unit tests agains the actual hardware instead of mock objects.

Billy Donahue

unread,
May 15, 2015, 4:09:56 PM5/15/15
to Patricia LaRue, Google C++ Testing Framework

You can use EXPECT_* expressions to check on the results of function calls whether they're virtual or not.
So yes, if I understand your question.

On Fri, May 15, 2015 at 11:21 AM, Patricia LaRue <patricia...@gmail.com> wrote:
We are attempting to use GoogleTest to test C++ linux software and embedded software.  My manager wants to know if we can run unit tests agains the actual hardware instead of mock objects.

--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Grenning

unread,
May 18, 2015, 9:12:07 AM5/18/15
to googletes...@googlegroups.com
Hello Patricia

You can write tests against the actual hardware and that is a good idea when practical.  I would not call it a unit test (unless you consider you are unit testing the hardware) I'd call it an integration test.  You might want to look at this paper on how hardware in the loop fits in: https://wingman-sw.com/articles/progress-before-hardware. I'd put hardware in the loop at what I call stage 4.  A more refined version is in my book Test-Driven Development for Embedded C.

When hardware is in the loop, can you get the needed feedback from the hardware to know if the code is working? For example, if it is a flash device, you can read back what you write to memory as a test.  Let's say it is a serial port, then you need a loopback connector.  Let's say its an LED.  You then need a way to look at it.  Full instrumentation with a photo sensor is probably not worth it (but may be in your application).  A partially automated test may be more suitable and at this point maybe a unit test harness is not what you want.

Using the actual hardware is not a substitute for automated unit testing with fakes and mocks.

Want to say more about your hardware?

Hope that helps, James

--------------------------------------------------------------------------
James Grenning - Author of TDD for Embedded C - wingman-sw.com/tddec

Patricia LaRue

unread,
May 29, 2015, 12:10:22 PM5/29/15
to googletes...@googlegroups.com
Hi, James:

I just ordered your book!  Thanks for the info.  :-)

Patricia
Reply all
Reply to author
Forward
0 new messages