-
Notifications
You must be signed in to change notification settings - Fork 301
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
ClassesShould.callMethod and subclasses #71
Comments
|
The API method
What I don't understand is, why
with your example class, and it reports
I've checked this on master, which is pretty much ArchUnit 0.8.0, can you verify, if the code above really doesn't fail for your example with the current version? |
I've checked it against 0.8.0 and it's reproducible. With the example class in the first comment @Test
public void noMethodShouldCall_printStackTrace() {
JavaClasses classes = new ClassFileImporter().importClasses(Example.class);
NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS.check(classes);
} is green but should fail, and @Test
public void noMethodShouldCall_printStackTrace_importExceptions() {
JavaClasses classes = new ClassFileImporter().importClasses(Example.class, Exception.class, RuntimeException.class);
NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS.check(classes);
} fails as expected. When it comes to evaluate the AssignableToPredicate, |
Well, this is interesting... In an empty project I see my described behaviour. When I copy+paste the code to archunit/src/test/java to commit an example I see your described behaviour. The difference is the property |
Oh yes, this is always confusing (I've come across it before). That's why I normally set that |
Since this is pretty much a known limitation (I don't see any way to fix this, since if classes are not imported, ArchUnit just can't know anything about their structure), can I close this issue? |
I think we should adjust the documentation and javadoc of |
I'll do that, the only problem is, that this is really a basic concept of everything. So even if I add it to |
Sounds good to me. |
… all imported classes and the resolution behavior. Issue: #71 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
I've tried to add more documentation to those classes, can you check, if this is understandable? Do you think this would have helped you to quicker get to the root of the behavior of your example? |
… all imported classes and the resolution behavior. Issue: #71 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Thanks, this is a very good improvement and will help others a lot! |
Okay, glad it helps 😃 |
… all imported classes and the resolution behavior. Issue: #71 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
For reference: (I started looking into this since I was running into a weird case where a |
I want to check that no class prints exception stack traces directly to stderr. My attempt was this:
Actual: The check is green.
Expectation: The check fails for
printStackTraceOfException
andprintStackTraceOfRuntimeException
.If I replace to
callMethod(Exception.class, "printStackTrace")
then the check fails forprintStackTraceOfException
but not forprintStackTraceOfRuntimeException
.The text was updated successfully, but these errors were encountered: