Currently our "unit tests" in JBM are actually a mixture of pure unit tests and
integration tests.
Pure unit tests should not have any dependencies on other components - so that means they
shouldn't use MINA, database, JGroups etc.
For the JBM 2.0 timescale one of my goals is to clean up the separation between unit tests
and integration tests.
This means each component should not deal directly with the third party component
interface, but we should abstract out our own interface(s).
We then create a mock implementation of that interface(s) which is used for unit testing.
E.g. for our clustering tests, we currently use JGroups directly. Instead we should
abstract out our own group management interface(s) which suits the need of JBM (actually
we kind of have this already), then we create a mock implementation - which for unit tests
trivially just forwards messages directly in vm. We would then have another implementation
for the real world which actually uses JGroups.
Similarly for the wire format - instead of calling the MINA interfaces directly - we
should abstract out that subset of functionality we need in a set of interface(s) and
create a mock implemention that just forwards requests/responses directly invm. The unit
tests should then use the mock implementation.
It's not going be overnight that we refactor all our tests to work this way, but for
the new work we should certainly aim to do it in this way.
One benefit of doing this (certainly for clustering anyway) is our test suite will be
lightning fast!
And, as Adrian has pointed out many times probably ;) , we can create interesting error
conditions that would be hard to do with the real product.
Testing failover also becomes very fast and thorough with mocks, we can cause failover to
occur at any point in message passing, without having to start lots of servers up (which
can take ages) and it all can run in vm.
Once we get over the initial mindset of doing it this way, I think we'll really see
the benefits :)
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105328#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...