You can easily do this with designing your components that way. It's painful, and often not worth it if the overhead is too much, but here's an example in C++
Foo.h contains
class FooImpl;
class Foo
{ // calls here that require interaction with foo.
FooImpl *foo_impl;
};
Foo.cpp can then include FooImpl.h which references FooImpl.cpp -- which in turn can have FooImpl.t.cpp which is a unit test for FooImpl.
This obviously will not stress interdependencies and bugs, but you can make tests for larger component behavior too. (At the limit, you have to consider the costs of your tests...hmm..)
You can easily do this with designing your components that way. It's painful, and often not worth it if the overhead is too much, but here's an example in C++
// calls here that require interaction with foo.
Foo.h contains
class FooImpl;
class Foo
{
FooImpl *foo_impl;
};
Foo.cpp can then include FooImpl.h which references FooImpl.cpp -- which in turn can have FooImpl.t.cpp which is a unit test for FooImpl.
This obviously will not stress interdependencies and bugs, but you can make tests for larger component behavior too. (At the limit, you have to consider the costs of your tests...hmm..)