Package org.jboss.weld.junit5.auto
Annotation Interface ExcludeBeanClasses
@Retention(RUNTIME)
@Target(TYPE)
@Inherited
@Repeatable(All.class)
public @interface ExcludeBeanClasses
@ExcludeBeanClasses excludes a set of classes with bean defining annotations (e.g. scopes) from automatic
discovery. This can be helpful to allow replacing bean classes with a different implementation, typically a mock.
This annotation works as an inverse of AddBeanClasses hence usually requires actual bean implementation
classes as parameters.
NOTE: This annotation will only exclude beans defined by class annotations. It will not exclude beans of the
specified type that are defined by Produces producer methods / fields or synthetic beans.
Example:
@EnableAutoWeld
@ExcludeBeanClasses(Foo.class) // Excludes Foo bean class from automatic discovery
class TestSomeFoo {
@Inject
SomeFoo someFoo; // SomeFoo depends upon application scoped bean Foo
@Produces
Foo mockFoo = mock(Foo.class); // mockFoo is now produced in place of original Foo impl
@Test
void test(Foo myFoo) {
assertNotNull(myFoo);
assertEquals(myFoo.getBar(), "mock-foo");
}
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceContainer annotation for repeatableExcludeBeanClasses. -
Required Element Summary
Required Elements
-
Element Details
-
value
Class<?>[] value
-