Describe the bug
Basically what I have is class C1, which implements 2 interfaces I1 and I2. Class C2 then injects those 2 interfaces. The actual (non-test) code runs well, but in testing one of the mocks is not called.
It will probably be the simplest to understand with some pseudo code, as I have a hard time explaining the problem with words.
class C1 implements I1, I2 {...}
class C2 {
@Inject I1
@Inject I2
method() {
I1.m1()
I2.m2()
}
}
@QuarkusTest
class Test {
@Inject C2
@MockInject I1
@MockInject I2
@Test
test() {
when(I1)...
when(I2)...
C2.method()
verify(I1) - NOT CALLED
verify(I2) - CALLED
}
}
From what I understand what happens is that the mocks replace the actual implementation, but that does not seem correct to me, because the implementation is not what I really want to mock or worry about.
Now... Does this qualify as a bug, or is it a "feature"? Is there some workaround except just creating interfaces that are the "same" as implementations (one interface per class)?
Describe the bug Basically what I have is class C1, which implements 2 interfaces I1 and I2. Class C2 then injects those 2 interfaces. The actual (non-test) code runs well, but in testing one of the mocks is not called.
It will probably be the simplest to understand with some pseudo code, as I have a hard time explaining the problem with words.
From what I understand what happens is that the mocks replace the actual implementation, but that does not seem correct to me, because the implementation is not what I really want to mock or worry about.
Now... Does this qualify as a bug, or is it a "feature"? Is there some workaround except just creating interfaces that are the "same" as implementations (one interface per class)?
Expected behavior Both mock get called.
Actual behavior One mock gets called.
To reproduce
git clone https://github.com/blazmrak/inject-mock-issue.git mvn clean test
Environment (please complete the following information):
uname -a
orver
: 10.0.19042.804java -version
: 11.0.10mvnw --version
orgradlew --version
): 3.6.3https://github.com/quarkusio/quarkus/issues/15411
$upstream:15411$