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

Merged

Conversation

Sparkymann
Copy link
Contributor

@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

@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
Contributor 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.

@codecholeric codecholeric force-pushed the fix-failed-junit-tests-while-filtering branch from d42985a to dd87277 Compare December 1, 2024 15:25
Before if everything was filtered out the filter also tried to remove the root descriptor which then failed with

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

Signed-off-by: Ilya Safonov <[email protected]>
@codecholeric codecholeric force-pushed the fix-failed-junit-tests-while-filtering branch from dd87277 to ba0b287 Compare December 1, 2024 15:26
@codecholeric codecholeric merged commit 348e92d into TNG:main Dec 1, 2024
21 checks passed
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.

4 participants