Adjust AnalyzeClasses annotation to support individual classes as parameter#1569
Adjust AnalyzeClasses annotation to support individual classes as parameter#1569TheManWhoStaresAtCode wants to merge 1 commit intomainfrom
Conversation
…ameter Relates to #1195 Signed-off-by: Andreas Zöller <andreas.zoeller@tngtech.com>
11e740b to
f6a08b9
Compare
StefanGraeber
left a comment
There was a problem hiding this comment.
looks good, just some comment and naming updates I'd prefer
| * <li>{@link #locations()} - specify custom locations via {@link LocationProvider}</li> | ||
| * <li>{@link #wholeClasspath()} - import all classes on the classpath</li> | ||
| * </ul> | ||
| * These options can be combined. If no option is specified, the package of the annotated test class will be imported. |
There was a problem hiding this comment.
I don't find it obvious whether the different options are used as union or intersect.
AFAIK it is a union, so each option can only add more classes.
Should we make that clear?
docs/userguide/009_JUnit_Support.adoc and archunit-junit/src/main/java/com/tngtech/archunit/junit/internal/ClassCache.java confirm this assumption
| * <li>{@link #locations()} - specify custom locations via {@link LocationProvider}</li> | ||
| * <li>{@link #wholeClasspath()} - import all classes on the classpath</li> | ||
| * </ul> | ||
| * These options can be combined. If no option is specified, the package of the annotated test class will be imported. |
There was a problem hiding this comment.
same here. can we make clear that each option adds more classes and never reduce the selection?
docs/userguide/009_JUnit_Support.adoc and archunit-junit/src/main/java/com/tngtech/archunit/junit/internal/ClassCache.java confirm this assumption
| } | ||
|
|
||
| @Test | ||
| void passes_AnalyzeClasses_with_new_classes_property_to_cache() { |
There was a problem hiding this comment.
I don't like names like "new" because it will not be new at some time. Please remove that from the test name
| verify(classCache).getClassesToAnalyzeFor(eq(AnalyzeClassesWithClassesProperty.class), classAnalysisRequestCaptor.capture()); | ||
| ClassAnalysisRequest request = classAnalysisRequestCaptor.getValue(); | ||
| AnalyzeClasses expected = AnalyzeClassesWithClassesProperty.class.getAnnotation(AnalyzeClasses.class); | ||
| assertThat(request.getClassesToAnalyze()).isEqualTo(expected.classes()); |
There was a problem hiding this comment.
why do you use the classes from the annotation here but an explicit empty for other properties like getPackageNames?
Feels inconsistent to me
| @Test | ||
| public void gets_all_classes_specified() { | ||
| JavaClasses classes = cache.getClassesToAnalyzeFor(TestClass.class, new TestAnalysisRequest() | ||
| .withClassesToAnalyze(getClass())); |
There was a problem hiding this comment.
maybe getClass() -> this.getClass() in both places to make it more obvious?
As suggested in the ticket adjust the annotation to have a new classes property to select individual classes as an additional option.
Resolves #1195