Testing integration with non-dependencies

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
alberto56's picture

Hi all,

Say I have a module A, which has some features which work with module B, but module B is not a dependency.

To test said features, I create a whole new "Test A B" module whose sole purpose is to have module A and module B as a dependency, and run tests against features which require both. "Test A B" module is stored in the "tests" subfolder of module A.

Wondering if that's the best approach, and if you are using any others.

Thanks,

Albert.

Comments

Hello Alberto, IMHO for

VinceW's picture

Hello Alberto,

IMHO for module A to use all features there is a dependency on module B. (If you think I'm wrong on this, please correct me)
So on order to run all tests for module A, the tests -must- include a testing of the existence of module B (or even perhaps the fact if module B is enabled)
The tests are only for module A, so they can reside in the module folder, no need for a subfolder

If you're propagating 1 module - 1 (specific) task, you could rip all the module B features out of module A and create a module C (or a subdir/page) for them and write the tests for C in the C folder. Tests for module A should then only be for module A and tests for module C should include tests for existence/enabled modules A and B.

That way you can keep your dependencies clearer and maintenance more easy.

just my 2 cents :-)

Best,
VinceW

-=[ Your Information Matters ]=-

Ideally, I would never have

carlescliment's picture

Ideally, I would never have features that depend on two modules. Dependencies are the most usual problems when dealing with tests.

If the feature needs both modules working together, may be you should consider moving some code from the module A to B, so that module B can provide the feature by itself.

Once the feature is isolated, then you can test it entirely in the module B, and module A can use this functionallity without having to care about covering it with tests again.

Regards,

Carles