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

fix fail test run with enabled junit.testFilter option #1361

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

Conversation

Sparkymann
Copy link

@Sparkymann Sparkymann commented Oct 7, 2024

Hi! There is a problem if you enable the junit.testFilter setting, and there are other tests in the project besides arch-unit
Exception:

Caused by: org.junit.platform.commons.PreconditionViolationException: cannot remove the root of a hierarchy

In PR fix a condition so that non-ArchUnit descriptors are not checked
Tested the changes in my test repository https://github.com/Sparkymann/archunit-test
Failed workflow: https://github.com/Sparkymann/archunit-test/pull/1/checks
Corrected: https://github.com/Sparkymann/archunit-test/pull/3/checks

Review: I think this is a safer way to do it. In the end, the error says "can't remove the root of a hierarchy", so it makes sense to exactly guard against this, and also it then only uses the general JUnit Platform API and doesn't rely on ArchUnit specifics (and `AbstractArchUnitTestDescriptor` is more an implementation detail, it's more by accident that the rule descriptors, etc., inherit from this, but the engine descriptor doesn't).
@codecholeric
Copy link
Collaborator

Thanks a lot for taking care of this! I do have one suggestion that I added as a fixup (see the commit message for the reasoning). In a nutshell, I think we can solve it a little safer by checking isRoot() instead of relying on the ArchUnit internal class hierarchy.
Does this make sense to you? Then I'd squash and merge it...

@codecholeric
Copy link
Collaborator

BTW: To get throught the CI commits also need a DCO sign-off in your commit message (see https://github.com/TNG/ArchUnit/blob/main/DCO#L34). If you're fine with that I could also add the line for you if you want 😉

@Sparkymann
Copy link
Author

Hi! I'm sorry for the long wait.

I do have one suggestion

Thank you, I agree with your suggestion, it looks like more general decision

If you're fine with that I could also add the line for you if you want

I would be very grateful to you.

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