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

Support to target only Test classes #501

Merged
merged 1 commit into from
Jan 31, 2021
Merged

Conversation

pstanoev
Copy link
Contributor

@pstanoev pstanoev commented Jan 5, 2021

Sometimes it is useful to define rules about the tests them selves.
Like each test class should not be public, it should have name ending with "Test" etc.
This IncludeOption allows to target only test classes.

@codecholeric
Copy link
Collaborator

Thanks a lot for your contribution 😃 I agree that this makes sense!

Sorry that it took me so long to review, my pipeline is always too full 😞

I had some review remarks which I actually put into a commit.
One main thing is that I would not want the abstract class LocationPatternImportOption to be public (i.e. reachable from the outside). Also I'm not a big fan of sharing logic through inheritance. I.e. we never use this class in a polymorphic way, then that smells to me that we actually just wanted to share some logic. And for that I've had bad experiences with inheritance 😉 (on this small scale it's probably irrelevant, but composition over inheritance in these cases is more consistent to the rest of ArchUnit)
The other thing was, that booleans easily confuse me 😂 So passing a boolean exclude and then return exclude ? false : true or vice versa makes my brain cramp up too much. So I've tried to replace that by a Predicate based approach which I think is easier to read (i.e. TEST_LOCATION = or(MAVEN_TEST, GRADLE_TEST, ...) and simply inverting it via not(..) for the other ImportOption).

So feel free to check out my review commit and if it looks okay in the state that it is now, then please squash together all our commits into your first commit so I can merge it as one commit 😃

@codecholeric
Copy link
Collaborator

Hey, I just squashed everything for you and rebased on master. I hope that's okay! It's just that I'm gonna release today and I was thinking that you'd be happy to have your contribution already in this release instead of having to wait for the next one 😉

This is useful for ArchUnit tests on test classes, e.g. test classes should not be public.

Signed-off-by: Peco Stanoev <peco.stanoev@netcetera.com>
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
@codecholeric
Copy link
Collaborator

Okay, it's merged and ready to ship 👍 Thanks a lot for your contribution! 😃

codecholeric added a commit that referenced this pull request Feb 21, 2021
Sometimes it is useful to define rules about the tests them selves.
Like each test class should not be public, it should have name ending with "Test" etc.
This IncludeOption allows to target only test classes.
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.

3 participants