Question

I am new to unit testing, just getting into it using Check for C.

This is a question of unit testing theory. Let's say (because it is true) that I have a module of code that formats messages to and from a serial protocol. I have another module which implements a state machine sending and receiving those messages.

I am starting to write unit tests for the message send and parse functions, and plan to write tests for the state machine too. In each case I use mocks/stubs to fake out the other module (apologies if I am misusing any unit testing buzzwords here).

Is it also considered a good idea to test the two modules together? So I would build the real state machine with the real protocol engine, drive it with wire-level messages and see if the appropriate state transitions and messages came out.

In theory this would already be covered by the individual tests, though..

Looking for some general clues, don't have enough experience to have a feel for this yet.

Était-ce utile?

La solution

If you're testing the units together, it's no longer unit testing. This is integration testing. Integration testing is helpful when it's challenging to provide a mock for a particular unit.

In your case, if the modules are cleanly separable, adding integration tests for these units may be redundant.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top