Skip to content

Prevent simultaneous usage of @InjectMock and @InjectSpy on the same bean during build #50163

@BegoMaier

Description

@BegoMaier

Description

When a bean is accidentally annotated with both @InjectMock and @InjectSpy, some tests start failing sporadically. This makes test runs flaky and unpredictable because the framework does not clearly handle this conflicting situation.

@QuarkusTest
class AnnotationTest {

    @InjectMock
    @InjectSpy
    TestBean testBean;

    // ... tests here e.g. with mockito.verify
}

Expected Behavior

Fail fast during build or test setup when a single bean is annotated with both @InjectMock and @InjectSpy.

Actual Behavior

Currently, no immediate error is raised, but tests may fail inconsistently at runtime, which makes it hard to diagnose the root cause.

Suggestion

Please add validation logic that prevents the simultaneous use of @InjectMock and @InjectSpy on the same bean. This would avoid hidden, non-deterministic test failures and make the developer experience clearer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions