Skip to content
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

improve rule to not fail for classes with no tests in their packages #1368

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

krzysztof-owczarek
Copy link

@krzysztof-owczarek krzysztof-owczarek commented Oct 23, 2024

This will improve the existing rule to test that test classes reside in the same package as their implementation. In particular the rule:

Should not fail if there are multiple test classes with the same simple name and some of the classes have no tests at all

Issue: #1367

@krzysztof-owczarek krzysztof-owczarek force-pushed the issue-1367-fix-multiple-impl-not-all-with-tests branch from 3012ef7 to 28c2894 Compare October 23, 2024 20:02
Copy link
Member

@hankem hankem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution! 💚
I'd like to take a closer look whether we can simplify the rule, but I already wanted to leave one comment on the test. 😉

@@ -0,0 +1,4 @@
package com.tngtech.archunit.library.testclasses.packages.correct.twoimplementationsonetestdir1;

public class OnlyOneImplementationHaveTestAndItIsMatchingImplPackageTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your test to cover the use case of #1367, this should be

Suggested change
public class OnlyOneImplementationHaveTestAndItIsMatchingImplPackageTest {
class MultipleImplementationsWithOnlyOneTestAndInRightPackageTest {

to make your new test actually fail with the old implementation. 🙂

In addition: I'd drop the AndInRightPackage part from this name: It's a relevant aspect to have classes with the same simple name in different packages, so: Is it right or is it wrong??
How about SimpleNameThatOccursInSeveralPackages?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reneming classes at the end and forgot about that one 🤦 Thanks for this suggestion - applied!

@krzysztof-owczarek krzysztof-owczarek force-pushed the issue-1367-fix-multiple-impl-not-all-with-tests branch from d494fc0 to b87bd2f Compare October 25, 2024 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants