-
Notifications
You must be signed in to change notification settings - Fork 30
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
Make annotations usable as meta annotations #223
Comments
Hello, bellow are my thoughts/observations.
We use that only for scanning - basically determining what classes to register into a synthetic bean archive for given test.
This is not true I am afraid; the CDI annotation
Right, this is a workaround for what I stated as the problem with the discovery of a producer method. You basically circumvent that by declaring such bean to be a synthetic bean with value coming from the [mocked] field. With all of the above, I am not sure I understand what exactly you ask for. If you are willing to keep your custom |
@Adrodoc55 could you please clarify your use case WRT my comment above? |
It would be great if annotations such as
@ExcludeBean
would add@Target(ElementType.ANNOTATION_TYPE)
to allow their usage as meta annotations.This is a feature that JUnit-Jupiter offers for pretty much all their annotations and I find it really useful: https://junit.org/junit5/docs/current/user-guide/#writing-tests-meta-annotations
You wouldn't even have to change anything other than the annotation target, because you already use JUnit-Jupiters
AnnotationSupport
:weld-testing/junit5/src/main/java/org/jboss/weld/junit5/auto/ClassScanning.java
Lines 91 to 93 in 61df95c
Motivating Example
For example I have a test that uses
@EnableAutoWeld
and@ExtendWith(MockitoExtension.class)
and to produce a mock in this test I have a field like this:If I could use
@ExcludeBean
as a meta-annotation, I would be able to define a custom annotation@CdiMock
and reduce the field declaration to the following:Now currently I can't quite achieve this, because
@Mock
has the same issue as@ExcludeBean
, but I opened a ticket there as well: mockito/mockito#3482@Produces
and@ApplicationScoped
on the other hand can easily be added automatically forCdiMock
fields by subclassingWeldJunit5AutoExtension
and adding the following CDI extension inweldInit
:The text was updated successfully, but these errors were encountered: