-
Notifications
You must be signed in to change notification settings - Fork 298
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
Provide basic rule definitions for fields, methods, constructors... #38
Comments
Hi @codecholeric , do you already have ideas how to design the DSL for My first idea would be something newly specific for that like this:
This would enable the opportunity to reuse all
This would also lead to my next question, I would like to write ArchTests for specific classes only to make sure, that a certain constructor is annotated with This would probably be possible with something like this:
However one could argument that this is also easily possible with java.lang.Class even:
However only the existence of ArchUnit made me think of such test cases for the first time. |
I pretty much had the same idea about reusing the class predicates for member assertions, my idea was, to call it
😉
Other than that, ArchUnit was created with a strong idea of providing an "extension" of reflection, so if you only use a subset, it might be well possible to assert all those things with reflection alone. However, I would use ArchUnit anyway, simply for having all tests together in a consistent way. (only talking from my own experience, I used to write those tests with a whole arsenal of tools from reflection to AspectJ, and it certainly doesn't make it easier to understand, where certain new tests should go and which places you have to observe in the CI build) Anyway, this issue will unfortunately only provide the basic entry point for fields, methods, ..., you'll have to be patient to get the full fluent API 😉 |
…te) / should(predicate) methods to syntax. Unfortunately anonymous instantiations of abstract classes with varargs constructors cause a Javadoc bug up to JDK 11, thus all anonymous instantiations of ArchCondition had to be replaced by inner classes :-( This should not be a common problem for users of ArchUnit though, since usually there will be no Javadoc created for test code. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…ion test for members syntax. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
@codecholeric I saw your commits where you are adding support for fields and methods in archrules, it looks great, I am currently working on a task of verifying that methods annotated with a specific annotation have an attribute set up. Do you know if these changes will be part of the next release? Thanks. |
@raspacorp Yes, this is planned for the next release. However I don't have a fixed date except for sometimes within the next 2 months 😉 |
…te) / should(predicate) methods to syntax. Unfortunately anonymous instantiations of abstract classes with varargs constructors cause a Javadoc bug up to JDK 11, thus all anonymous instantiations of ArchCondition had to be replaced by inner classes :-( This should not be a common problem for users of ArchUnit though, since usually there will be no Javadoc created for test code. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…ion test for members syntax. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…there for classes and match properties of members as well, like visibility or names) Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…te) / should(predicate) methods to syntax. Unfortunately anonymous instantiations of abstract classes with varargs constructors cause a Javadoc bug up to JDK 11, thus all anonymous instantiations of ArchCondition had to be replaced by inner classes :-( This should not be a common problem for users of ArchUnit though, since usually there will be no Javadoc created for test code. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…ion test for members syntax. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…te) / should(predicate) methods to syntax. Unfortunately anonymous instantiations of abstract classes with varargs constructors cause a Javadoc bug up to JDK 11, thus all anonymous instantiations of ArchCondition had to be replaced by inner classes :-( This should not be a common problem for users of ArchUnit though, since usually there will be no Javadoc created for test code. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…ion test for members syntax. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…there for classes and match properties of members as well, like visibility or names) Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…terface types instead of resolving runtime types via TypeToken (necessary to support more extended generics for complex members syntax with inheritance; we need to pass information about actual type parameters of generic interface types on, instead of using TypeToken on runtime types which will in parts yield <? extends #99...> types instead of the correctly bounded declared type available via public API) Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
…escription should be concern of PartialStep, not Parameters. Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Issue: #38 Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
We should add to
ArchRuleDefinition
the factory methodsGivenFields fields()
GivenMethods methods()
GivenConstructors constructors()
GivenCodeUnits codeUnits()
GivenMembers members()
that provide an easy entrance to speak about the respective objects, i.e. provide a
that(predicate)
andshould(condition)
fluent API. At some later point, this API can be extended for generally useful methods likedeclaredIn(clazz)
or similar.The text was updated successfully, but these errors were encountered: