Skip to content

Unit Tests: Cross-module inheritance forbidden #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lbajsarowicz opened this issue Apr 19, 2020 · 0 comments
Open

Unit Tests: Cross-module inheritance forbidden #182

lbajsarowicz opened this issue Apr 19, 2020 · 0 comments
Labels
proposal New rule proposal

Comments

@lbajsarowicz
Copy link

Rule

Inheritance from namespace other than \PHPUnit\... and the same that module is in is forbidden

Reason

TLDR: Avoid unnecessary coupling between modules.

While working with Unit Tests migration for Magento Commerce / B2B, we have faced multiple weird types of inheritance introduced - eg. Unit Test completely unrelated to Magento Catalog, inherited Unit Test from Magento Catalog to get the setUp executed and mocks created (that is the only reason). Changes introduced to Magento Catalog caused failures of Commerce modules Unit Tests. That is unacceptable, as the unit of responsibility for Magento Commerce module hasn't changed and if the mocks were independent - the test would still pass.

Implementation

CC

@slavvka @dmytro-ch

@lbajsarowicz lbajsarowicz added the proposal New rule proposal label Apr 19, 2020
magento-devops-reposync-svc pushed a commit that referenced this issue May 31, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Version 23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal New rule proposal
Projects
None yet
Development

No branches or pull requests

1 participant