On Fri, Jan 15, 2010 at 09:01, Vincent Massol <vincent(a)massol.net> wrote:
Hi,
Just got an idea: Create an AbstractComponentTestCase implementation that does this in
its setup/init() method:
- automatically ask the Component Manager for the list of dependencies for the component
under test (can be done with a generic for example to know which component class is under
test) and for each of them register a mock implementation automatically.
Yes good idea. But i think you should use an annotation to setup the
main component tested in your testcase (you can't find the class from
a generic anyway).
The advantages:
- remove lots of boilerplate testing code to register mocks of dependent components (all
the component descriptor creation)
- ensures that top level dependencies are mocked and not deps of deps (best practice)
- ensures each component is tested in isolation thus focusing on testing what it does
- remove the need for the execution context or configuration source specific inits we
have in current AbstractComponentTestCaset implementation
- allow to call the annotation loader to register *only* the component under test (and
its graph of components) rather than initializing *all* components for each unit test!
This will multiply by x100 the speed of our unit tests I believe.
WDYT?
Thanks
-Vincent
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne